Using Sets to Filter in Tableau: Mastering Advanced Data Visualization

Blog | February 4, 2021 | By Caitlyn Garger

Using Sets to Filter in Tableau: A Comprehensive Guide

Harnessing the Power of Sets for Data Filtering in Tableau

Mastering Tableau Sets: Advanced Techniques for Data Visualization

One of the greatest features of Tableau is that the end-user can interactively drill-down into their data to get to the nitty-gritty details if they desire. Typically, we use “Filter Actions” to filter sheets on a dashboard based on a selection in a sheet.

Here is a simple dashboard that I have put together to illustrate just that. On the top, I have a highlight table showing distinct orders by Region, Category, and Customer Segment. If I make a selection in the highlight table, I will see the Customer Details table get filtered.

Filter Action Settings:

Understanding Sets in Tableau

Types of Sets in Tableau and Their Applications

Creating Sets in Tableau: Step-by-Step Guide

Advanced Set Techniques for Enhanced Data Filtering

The only issue with this is that when I make a selection in either the Sub- or Grand Totals, the Customer Details sheet does not get filtered down at all:

If you aren’t showing Sub- or Grand Totals, then this won’t be an issue.
Yet, if you are, you can’t leave this as is and expect an end-user to know that Filter Actions will not work on the totals.

The solution here is “Set Actions”. Released in v2018.3, Set Actions allow developers to dynamically change the membership of a set based on interactions occurring in a worksheet.

To filter the Customer Details sheet correctly, we need to create a set on each dimension that is currently being used to structure the highlight table. Currently, we are using Segment, Region, and Category:

Therefore, we need to create three sets; one for each. (They can be empty upon first creation. We will be using Set Actions to add/remove members from each set) With the three sets created, it is now time to add some Set Actions. The below example is for the Category Set Action:

**Make sure that:
1) “Running the action will” reads: Assign values to set
2) “Clearing the selection will” reads: Add all values to set

After setting up all three actions, if you try to make a selection in the highlight table expecting it to filter the detail sheet below, you’ll see that nothing happens. That’s because, while you are affecting the membership of each set, you have not attached any logic to the detail sheet to consider each set. This is where you can create a very simple Boolean logic calculation to use as a filter:

The above calculation is based on the fact that sets will be true if at least one member exists. The sets will include ONLY the end-user’s selected dimensions or, since we made sure that “clearing the selection will” add “all values” to set, you can have “all values” in the set. (Meaning, the sets will never be empty, therefore, will never return false).

Static Sets vs. Dynamic Sets: When to Use Each

Combining Sets with Other Tableau Features for Powerful Analysis

Practical Examples: Real-world Applications of Set Filtering in Tableau

Tips and Tricks for Optimizing Set-Based Filtering in Tableau

Drag this newly created “Filter based on Sets” field onto the detail sheet Filters shelf and select “True”.

Now, when you make a selection in the highlight table, you will see the below details sheet get filtered, even for the Sub- and Grand Totals:

Please feel free to visit my profile to check out this and other visualizations.

Thanks for reading.

caitlyn-garger
About the Author
Business Intelligence (BI) and Data Analytics consultant/trainer with a passion for using data to solve complex problems and teaching others how to use the power of visualization to bring their data to life.
Caitlyn GargerTechnical Team Leader - Visual Analytics | USEReady