If you’ve been reading blogs & watching videos about Tableau, you’ve probably heard someone mentioning Set Actions. A quick google search would show hundreds of tutorials teaching how to do Set Actions. The problem is that there are not many blogs sharing examples and use cases of Set Actions in Tableau. What can Set Actions do? How can it enhance the interactivity of your dashboard? What are some good use cases? These are the questions that I would like to answer in this post. Although I will also include a brief section on how to create set actions, the focus is on introducing the cool examples to give you ideas for your next Tableau project, rather than teaching you how to do it. The best way to learn is to go to the use cases I introduced here, download the Tableau workbook (or watch the solution video, if available), and reverse engineer yourself.

Assumed Knowledge: None (but to actually make one, you need to know set action)
Level of Difficulty: Easy – Difficult (see each section)

Example 1: Drilling down to a lower level

Drilling down is one of the most common examples of Set Actions in Tableau and has already been covered dozens of times in various blog posts and Workout Wednesday. There are also solution videos and workbooks for you to download if you cannot figure out how to do these yourself.

Drilling down on scatterplot/map

Level of difficulty: Intermediate

This is a use case introduced on Workout Wednesday where you can click on a state and drill down to the city level, and double click to go back to state level. The challenge uses a scatterplot but you can easily do this on a map instead.

Drilling down on line chart & tree map

Level of difficulty: Intermediate

This is another cool example of set actions for drilling down your Tableau dashboard. The solution isn’t on WOW Website so you should check out this post on hipstervizninja if you’re stuck.

Example 2: Add & Remove Items from a Set

Compare multiple selected states/countries

Level of Difficulty: Easy

This is a really sweet and easy use of Set Action. Adding and removing states from the set, updating the total contribution at the top. The limitation of this use case is that it’s only available on Tableau 2020.2 onwards because it uses the function remove. In earlier Tableau’s version, you can only add to a set but from Tableau 2020.2, you can remove an item from a set.

Compare multiple selected items

Level of Difficulty: Easy/Intermediate

A similar but more complex example as the above. Instead of adding states/countries using a map, Lorna uses a bar chart to add items on a pizza. The set action itself is pretty easy, but Lorna adds other features which make this exercise a bit more challenging than the above.

Example 3: Conditional View for Member of a Set

In lack of a better name, I just call this group of examples ‘conditional view’.The idea is that you create a dual-axis chart and a calculation so that the view only shows for members of the set, otherwise, the view doesn’t show anything. It’s okay if this doesn’t make sense now, scroll down to see the gif and see what I meant.

Route Map for Members of the Set

Click to go to Tableau Public

Level of Difficulty: Intermediate

I wrote about how to create this viz in a previous blog post, 6 way to enhance your map (or see instruction video). It’s great if you don’t want to clutter your map with so many lines. The downside is that the screenshot on your Tableau public doesn’t look as sexy, but a very simple map with bubbles.

Conditional Line Chart for Members of the Set

Level of Difficulty: Intermediate/Difficult

I took the inspiration from the really cool COVID19 viz created by my coach, Craig Dewar for this Water & Sanitation viz. It’s not that difficult to create if you know the calculation but it took me a while to come up with this, because of the added difficulty with year.
I wanted the scatterplot to show all countries in the latest year if nothing is selected (empty set) and shows the trend over time if some countries are selected. To do this, I created 3 calculations.

One to count how many countries in the set.

IF [Country Set] THEN [Country]
ELSE NULL
END

The second calculation is to show line for only members in set or show scatterplot when the set is empty

// If empty set, then show latest year (which is 2014 in this dataset)
IF SUM([Number of countries in set]) = 0 THEN
IF ATTR([Year]) = 2014
THEN AVG([x-axis Value])
END// Otherwise, show all years for countries in set
ELSE AVG([x-axis Value])
END

The last calculation is to filter. If the set is empty, show all countries, otherwise, only show members of the set

IF {FIXED : COUNTD([Countries in Set])} = 0
THEN [Country]
ELSE [Countries in Set]
END

To make the bigger circle for the latest year, create another calculation and drag it to size

IF [Year] = 2014 THEN 1
ELSE 0
END

Since my dataset was incomplete with values for some countries only for 2015, but containing values for most countries in 2014, I had to manually type in the year. If you would like Tableau to show the latest year in your dataset dynamically, consider using LAST()=0 instead of typing in the year.

Example 4: Highlight & Filter viz-in-tooltips

Highlight viz-in-tooltips

Click image to go to Tableau Public

Level of Difficulty: Easy

Tableau allows filtering in Viz-in-Tooltips by changing the tag when you add the viz into your tooltips. However, there is no highlighting action. When we want to display the full list of categories for comparison but only highlight the one being hovered over, set action is the solution! In the example above for my Water and Sanitation Viz, I want to show India’s level of access to sanitation but also want to show how it compares with the average of different HDI groups so I didn’t want to use filtering. We can see that India has only 39%, way lower than the average of Low HDI Group, although its HDI is in the Medium Group. To do this, I used Set Action on Hover instead of select. You may also want to change your tooltips setting from Responsive to On Hover, because otherwise, depending on whether your mouse is, the tooltips may show without the set action.

Filter viz-in-tooltips

Tableau allows you to do some filtering for ViT but sometimes it doesn’t work! When that fails, try Set Action instead. Sadly, I couldn’t make a failed ViT for my water and sanitation to show you can do it using Set Actions. I definitely saw it failed in the past especially after you filter to a certain date, the chart updates but the ViT doesn’t.

Example 5: Create a selection button

Source: VizZenData.com

Level of difficulty: Easy

I normally do this using parameter action but after reading this article, I realise that it’s even easier with set action. Lindsay Betzendahl wrote a step-by-step tutorial on how to do this on viz zen data.

How to Create Set Actions

As promised, I outline the basic steps of how to create set actions below. However, depending on what you want to do, the calculation should change. I recommend trying out several examples above then you’ll get the hang of set actions, and even able to create your own creative use case.

  1. Create a set (usually empty)
    The reason for the empty set is that clicking on a chart/map will add that item to the set. The set will then update the view where the set is used (sort of like a filter).
  2. Create a calculation based on this set
    Usually, the calculation is based on an IF Calculation, such as *If [Set 1] then SUM([Sales])”. [Set Name] returns a boolean value (True or False).
  3. Use this calculation to create a view
    Once we have a calculation based on a set, we need to create a view using this set. You can think of this as a categorical value, In or Out of the Set. Since this is categorical data, you can use it to filter, or color, etc.
  4. Add Set Action
    Like the Dashboard Filter Action, you can configure the action, such as Select, Hover, or Menu. Set Action offers even more options than Filter, such as Add to the Set, Assign Value to the Set, or Remove value from the set.

Conclusion

I hope this post gives you some ideas and inspirations for your next viz project. There are more cool examples of set actions for Tableau if you go to Workout Wednesday website and type ‘Set Action’ in the search box.

 

 

 

 

 

 

Amy Tran
Author: Amy Tran

Amy hails from Vietnam and completed a bachelor’s degree in Economics at the Australian National University. While working a marketing role in Japan, she became interested in data analysis and began self-learning Tableau. She applied to join The Data School to gain knowledge and experience working with data in order to pursue a career in data analytics. In her own time, Amy is an avid blogger and also enjoys working on craft projects.