This blog post is about the difference between regular filters and parameter filters in Tableau. It uses the same dataset of my Spotify listening history that I used in my last blog about sets and groups.
With a regular filter, you can drag a dimension onto the viz and select all, some, one, or none of the things in that dimension. For example, you could look at my listening history over time and add a band filter to select a particular band.
Let’s try that out. Here’s a graph of the number of plays per month, with all bands added together into one line:
By dragging the band onto the detail shelf, we can see the plays over time of each band I’ve listened to. This is not a particularly useful graph:
To add a regular filter, just drag band up to the filter shelf as well, and choose the kind of filter you want. Easy as that. Now you have a filter where you can select individual bands, and see how much I’ve listened to them each month:
(although disclaimer, a line graph over time doesn’t always account for null values; here, it has drawn a straight line between February 2015 and June 2015, even though I didn’t listen to 65daysofstatic at all in the months in between)
That’s a regular filter. It can show any selection of bands you want, but you have to do all the work yourself. If that’s all you want to do, then great! That’s all you need.
But what if you wanted to plot my listening history for the bands I’ve listened to most in that time? Well, you could calculate the list of bands with the most plays, and then select the top five by looking at them, remembering them, and manually selecting them from the filter. But that’d be silly. Instead, you could edit the filter, select “top”, and then enter the number 5 in the box after choosing the top N by field:
That works just fine as well. But, what if you wanted to see the top two, or seven, or ten? You could edit the filter each time, but that’d be a right faff.
Instead, you can create a parameter filter. This will let you select the number of bands you want to see, and update the filter dynamically. Think of the parameter as like a variable or a placeholder for the number 5 which you can change without going into the edit filter box.
First, let’s create a parameter. We’ll set it as a range to give people the option to choose from the top 1 to 20, with a step size of 1 (i.e. every number between 1 and 20).
For now, this does absolutely nothing. If we right click the parameter and choose “show parameter”, it’ll turn up in the view but it won’t change anything:
To make the parameter work on the filter, we can put the band filter on again, and edit it. This time, instead of putting a number in the top N box, we can select the parameter we just created:
This will now update the filter with the number set by the parameter. Want to see the top two bands over time? Slide the parameter to 2:
The top five bands? Slide it up to five, and it’ll automatically update the filter:
Regular filters are fine, but parameter filters give you more control over the filters on your worksheets, and can be very effective tools for data exploration.