Using set actions to create a nested bar chart

by Hannah Murphy

This week at the Data School (DS24): Tableau 101. This included a session on sets, groups and set actions with the final hours spent on Workout Wednesday 2020 Week 25. This was most definitely a challenge but consolidated our understanding of what we'd learnt...if you're after a brain workout then I would recommend!

A nested bar chart is a simple but effective usage of set actions that allows the user to interact with supplementary data and directly compare between categories/sub-categories without compromising on space...

... and it's so simple to build!

Create your set

For a set action, you'll first need a set! Right click in the dimension you're going to use and select 'Create.'.. 'Set'. In this example I will be making a set based on the region.

Select 'Use all' and press ok. You now have your set ready to go!

Note: make sure you name your set something relevant so that you'll be able to find it again.

Build your bar chart

On a new sheet build a simple bar chart by putting your set on the row and measure on the column shelves.

In this example we will be looking at the sum of sales for each state within each region.

Here I have sorted the bars into descending order by SUM(Sales) and changed the fit to 'Entire View'

Write your calculation

Right click on your group and select 'Create' and 'Create Calculated Field'. The formula you will need is as below:

This calculation is essentially telling Tableau what information you want it to display when you set up your action.

Move this calculation to your row shelf next to your dimension.


Before you go any further, format your sheet:

  • Think about any tooltips and labels - I have chosen to use labels instead of my axes in this case
  • Remove any unnecessary gridlines
  • Think about colour
  • Remove field labels for your rows

Finally, Tableau has an automatic highlight action based on the bar selected. To override this you will need to create a calculated field called 'Dummy'.

Drag this to 'Details' on your 'All' marks card. You will need this for the next step!

Set up your actions

For the action to run on your viz, this needs to be done once the sheet has been added to the dashboard.

Firstly you need to set up your set action. Go to 'Dashboard' and then 'Actions' on the top tool bar to open the actions window. From there create a 'Change set action'; your action should look like this:

Create another, this time a highlight action. This is where your dummy calculation comes in:

Press OK twice and that's it! You should now have a bar chart that drills down into your subcategory when selected.

Workout Wednesday:

Finished example:

Sat 24 Jul 2021

Fri 09 Jul 2021