For my first post of actual content, I thought I'd start off with something that is quite simple but also is an extremely effective way to solve a problem that many Tableau developers face very regularly; that problem being the issue of restricting entries that appear in a Quick Filter list.
Essentially what this tip addresses is the need to allow the your users to make a selection from a list
of filter values but also for you as the author to be able exclude certain records from that filter list.
You may wish to do this because selecting (or even viewing) one of the extra values...
- may look untidy,
- may cause confusion,
- may result in an empty worksheet, or even
- cause a security issue.
So, after we've created our basic filter, what options do we have to be able to solve this problem?
Go to the Source!
|
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrS9NC6dt1x0CVzUX8qdCwQICB_FcSbH4Xrkw5Ne588TtQfZMH-gjJQtH2esnelURT3zCzMpWykLMjs8T8Jva0as9skv1oSMoTSu3nTrMZB9_9ZsIFePJ9khQfxybuVhTKQWP2YgPs5Rw/s1600/Blog+Post+2+Dirty+filter.png) |
This filter needs cleaning! |
|
One method is to set a Data Source Filter which you can do so in six simple steps:
- right-click the name of the data source
- click Edit Data Source Filters
- choose the field on which you will base your filters
- select the values you wish to exclude
- click the Exclude checkbox
- click OK twice
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUH9g65A3tVusmmycnyeGDWmzAMyMLh9iD5yVIHZzJhPkonHoWhtbgYSenZOgCg4NYihisEaUcpclosoITKoTF74MJ5h9fqXw3ANheN8KFWIVVQyTU3tYW-3Qmd5uD11mWQulZSq1fRP4/s640/data+source+filter.gif) |
How to create a Data Source Filter that excludes values from a dimension |
Any Quick Filter you have based on the field at step 3 will then refresh to no longer show the excluded values.
In this particular example, a couple more clicks are required to prepare the Quick Filter:
- open the context menu for the Quick Filter by clicking the down arrow in the top-right of the Quick Filter panel
- click Include Values
Now your users will be able to choose which values they wish to keep rather than choosing values to exclude from the view.
|
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi17_ESoJ_aFDR-xOlc-dOZjZmQvIHdRqdyoX0lipn8mMU5UR8yHnY_XRWYLV8Zh7TZJZqsBgHJDw28PHbsyYeQmQKM4t53VJZPCgQqYQdJ-ucezCOPQawCFE9JIVaPJlUcGQzp9-fNBKA/s320/change+to+include+filter.gif) |
Switch your Quick Filter from Exclude to Include |
|
Using a Data Source Filter to restrict Quick Filter entries is very simple to do but is quite brutal because excluding values at this level means that none of the rows that contain these values will be available to any worksheet that connects to your data source.
|
|
For example, let’s say there was a separate view in my workbook that showed inventory levels for different products in my retail store. Since we excluded the NULL Customer Name in the data source filter, we would not be able to see any new product lines. This is because no customers have bought them yet therefore would have NULL in the Customer Name field after joins.
Copy That, Good Buddy
The following is the most commonly described solution you’ll find around the Web and for good reason – it works! Although, it requires the source field be duplicated and there are a few more steps involved:
- duplicate your dimension
- rename the new dimension
- right-click your original dimension pill
- uncheck Show Quick Filter
- right-click your new dimension pill
- click Show Quick Filter
- bring up the context menu for the Quick Filter
- click Only relevant values
After choosing the ‘Only relevant values’ option those values previously excluded in your original dimension filter will disappear.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu8j2R8F2Ovu119i8VLzbRWJo9nZkQ7tGqtkqUTNHMFb5X9Wc4geOOFcVyGcHRfd3UjwIU4Pwm4i1n7cN5iP2GFVbsrnuGhIzH8xuUhKBIvQ_LTovRgadSgwkNXER7-TAN3wsSXC8EZso/s640/copy+technique.gif) |
How to restrict your Quick Filter entries with a cascading filter |
Sets Appeal
I find this option to be a little more elegant, simpler and fit for purpose. Sets already have a close relationship with filters and this requires no duplication of fields.
- right-click your dimension pill on the filters shelf
- click Create Set
- give your set a name
- click OK
- drag the newly created set and drop it directly on top of the dimension pill on the filters shelf
- right-click the set pill
- click Show Quick Filter
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIB4VRBOD8cNw4LXo0zg5dF9bKTrejDc2jq6_154XIWi16pqwseAF_AKcOuLfq3ziVJYjy381qhimLf7oFP59GfhWgyyk7VwMtBwm70NSO38nmHYO9DnsvL2l_rMJHA2KTr5zUz1qUKOQ/s640/sets+solution.gif) |
How to use Tableau sets to restrict your Quick Filter entries |
There you have it. The extraneous values have gone and your Quick Filter is now a neat and clean list.
One drawback of these methods is that you can't apply the same techniques to a filter that is based on Tableau's generated fields such as Longitude, Latitude or Measure Names. Measure Values can't be used either, but if you tried to create a dimension filter using Measure Values, Tableau will in stead create one using Measure Names.
If you have any questions or any thoughts on how to better solve this problem, please feel free to add a comment below.
TFB