Here’s a simple step by step on how to create a bar chart drill down by using set actions.
What is a set action?
Tableau notes that you can use ‘set actions to let your audience interact directly with a viz or dashboard to control aspects of their analysis. When someone selects marks in the view, set actions can change the values in a set.’
You can read more on set actions here: https://help.tableau.com/current/pro/desktop/en-us/actions_sets.htm
What we intend to make:
![](https://www.thedataschool.co.uk/content/images/wordpress/2020/11/Set-actions-long.gif)
Let’s get stuck in – We’re using Superstore data in this example but feel free to adapt this.
- Drag ‘Sales’ to the columns shelf and both ‘Category’ and ‘Sub-Category’ to the rows.
![](https://www.thedataschool.co.uk/content/images/wordpress/2020/11/Picture1.png)
2. Create a Set.
- Right click on ‘Category’ and then hover over create, this will lead you to ‘Set’ indicated by the two circles overlapping.
![](https://www.thedataschool.co.uk/content/images/wordpress/2020/11/Picture2.png)
- The set pop up will appear. You don’t need to select anything, simply name it ‘Category Set’ and click ok.
3. Create a calculated field to indicate what happens when you click on the set.
- Call this ‘SUB-CATEGORY’.
- In this case, it will be a simple if statement saying that if the category set is selected, then return me the sub-category, otherwise, return nothing which is indicated by an empty string ‘’
- This way, when you click a category, you will get back the members of the sub-category for what you selected only, the rest will be blank – you can see this in the image below.
IF [Category Set] THEN [Sub-Category]
ELSE ”
END
- Replace ‘Sub-Category’ on the rows shelf with this calculation.
4. Now to add those circles outside of ‘Category selected’
- To do this, you need to create another calculated field and name it ‘Category Selected’.
- Within this, you’ll need another simple IF statement as below:
IF [Category Set] THEN ‘● ‘
ELSE ‘○ ‘
END
+ [Category]
- You’re essentially saying that if ‘Category Set’ is selected then return the coloured circle and if not, then the empty one. This is one calculation that then gets added to a second one saying AND add those circles to ‘Category’.
- Notice the circles have a space after to account for the attachment to the category field.
- Drag ‘Category Selected’ into the middle of ‘Category’ and ‘Sub-Category’ on the rows shelf.
5. Now we need to add the set actions!
- To To do this, you go to worksheet, click actions, and add action.
- In this case, we want change set values indicated by the two circles overlapping.
- A pop up box as shown in the image below will appear where you can edit the set action.
- Name thus ‘Update Category Set’
- Make sure the source sheet is the sheet that you’re working in (I probably should have named mine better than sheet 1)
- You can pick what to run the action on. I prefer to click so it’s intentional
- Your target set data source will be superstore
- The set being used is ‘Category Set’
- Running the action will assign values to the set and clearing the selection will remove all values from that set
- This gives us the drill down sub-categories and then removes them.
- Press okay and test – your drill down should be working!
- You will now have two categories and so you can remove one.
- To do this, right click and untick show header.
![](https://www.thedataschool.co.uk/content/images/wordpress/2020/11/Picture6.png)
There you go – a simple drill down action that should hopefully give you the ability to explore data within it’s hierarchy.