By: Eric Parker
Eric Parker lives in Seattle and has been teaching Tableau and Alteryx for 5 years. He's helped thousands of students solve their most pressing problems. If you have a question, feel free to reach out to him directly via email.
Traditionally the set feature in Tableau is used to create a subset of predefined values. Those may be handpicked (i.e. How do these 5 products perform regionally?) or they may be chosen conditionally (i.e. Where are our top 100 customers by revenue located?). They are generally used to create predefined values you can filter on.
In version 2018.3, Tableau released a new feature called “Set Actions”. They allow sets to by created on the fly by end users based on their data point selections in a worksheet. They give you more flexibility to customize your visuals and make them more effective.
Imagine you are looking at a chart of GDP per country:
The GDP for the US is so much higher than the rest of the world that it’s not possible to tell which African country has the highest GDP relative to its neighbors. This is where set actions can be useful. If we create a set action based on what countries are selected, we can get the color legend range to adjust to fit just those countries.
Notice the difference after applying the set action:
It’s now much easier to tell that Nigeria and South Africa have the two highest GDPs in Africa.
Let’s look at another example. The way the Tableau hierarchy feature works is that you have to drill down on all segments of your data at the same time.
Here’s a hierarchy in action. After having created the hierarchy in the data pane you can hit the “+” button to drill down to the next level.
The problem is that hitting that button drills down on all the states at once. If you want to be able to select a single state and only drill down to see cities for that state, you need a set action.
Creating a set action begins by creating a normal set. We can create one based on the state field and just pick a single value for now:
Next, we can write a calculated field that incorporates the set to see how it works. This calculated field will only return cities for whichever state is selected.
Here’s what it looks like in use:
Now to make it dynamic. Hit the Worksheet dropdown on the Toolbar and select Actions.
From the Actions dialogue box you can hit the Add Action button and select Change Set Values.
Last, we’ll set up the Set Action to look like so:
When you Select a state, that state is added to the set. When the state is deselected, all states are removed from the set. Notice the dropdowns under Target Set. That’s how Tableau knows you are targeting the existing State Set so the action applies to that.
Here it is in action (with an instruction added to the worksheet title).
That’s it! If you found this helpful, check out our workshop taking place March 12th-14th, Tableau Dashboarding: From Mystery to Mastery. We’ll be teaching a lot more cool and useful tricks like this that you can implement to take your dashboards to the next level.