In my last blog, I talked about how to create sets in Tableau and use those sets to help you perform more in-depth analysis. In short, sets are a powerful way to divide members of a certain field into two groups, that is, IN and OUT, which can then be used as a filter or for assigning different colors or shapes. Understanding how sets work is fundamental before you decide to dive deeper into set actions. If you are a bit unsure about sets, you can still check out my previous blog here.
What is Set Action?
First off, what exactly does set action do? Well, this feature was first introduced in Tableau in the 2018.3 version. Prior to that, there were only three types of actions available, namely, Filter, Highlight, and URL. But a major drawback with those existing actions was they were limited to just one behavior, as indicated by their name.
With set action however, this constraint does not apply. For example, it can be applied across multiple worksheets simultaneously and supports different behaviors on each sheet. And these can all be customized by the user. Because of its extended flexibility, when it was first released, it suddenly opened up a whole new world of possibilities. Best of all, it is very intuitive to use once you understand how sets operate, and eliminates the need to learn various hacks and workarounds just to get the kind of interactivity on your dashboard.
Dynamic Highlighting with Color
When we drag a set onto the Color marks card, we can assign two distinct colors based on whether the element is within the set or not. For example, we can quickly create the following view by creating a set from the State field in the Sample Superstore data set. For demonstration purpose, I’ve only selected California for this set.
Looking at this view, have you wondered whether there is a way to make our set dynamic? In other words, we would like to make our set update dynamically based on our user’s selection on the map, so that only those selected states will be color highlighted.
This can be easily achieved through set action, which can be configured both for individual worksheet and a dashboard. Right now, our view is in a worksheet. Therefore, to configure the action, click on Worksheet –> Actions, and then adjust your settings as below. Basically, what this is saying is when a user selects something on the State map, it will update the State set, and further selections will add more states to the set, while the set remains unchanged when the user clicks away on the view.
After the configuration is done, say you would also like to highlight the states of Texas, Washington, and Florida, all you need to do is click on them.
Show Part of Whole
The previous view by itself won’t be very useful for any sort of analysis. But we can use the map as a way to dynamically update states in our set, while at the same time using the set to build another view. For example, we can look at how much total sales our selected states account for. We can build either a pie chart or donut chart to display this information. In your Tableau, open up a new worksheet and build the following view. You can use the quick table calculation to find out the percent of total for sum of sales.
To enable interactivity between our map and the pie chart, we need to put them together on a dashboard. Then we need to configure the set action again by clicking on Dashboard –> Actions, then use the same setting as we used for the worksheet but change the Keep set values to Remove all values from set. This will clear all members in the set when the user clicks away. Now it’s time to test out the set action you just built. Also remember to try out the Lasso Selection tool for the map, which I find very fun to use.
This blog has only demonstrated two of the most common uses of set actions. If you find this fascinating, I recommend checking out the following video or blog links. They go into much greater depth in explaining the capabilities of set actions. Mastering even just some of those techniques will make you appear awesome at Tableau.
Have a blast with set action!