In this blog, we'll explore how to create a drill-down bar chart in Tableau using the built-in Superstore Dataset. This bar chart allows us to drill down from category to subcategory with just a click on the category bar.
The term 'drill down' refers to navigating from a higher-level view of the data to a more detailed, granular perspective. This technique enables users to explore data hierarchies and reveal layers of information.
For example, as seen in the chart we'll be creating, users can move from initially viewing total sales by category to total sales by sub-category.
- Build the Bar Chart
Step 1 involves building the foundational bar chart. Put your SUM(Sales) on columns and your Category on rows.
- Add a Parameter
Create a new parameter that will select the Category we want to drill down on. This parameter will not be visible in our final viz as we will be clicking on the bars to select the category we want to look at.
- Add Worksheet Action
Under the 'Worksheet' tab you will see an option called 'Actions', select it and under 'Add actions' in the lower left hand corner select 'Change Parameter' which will pull up a window as seen below. This parameter action will allow us to change our category parameter by clicking on the bar for the category we want to drill down on.
- Create a Calculated Field
In order to pull up the sub-categories in the drill down we will need to use a calculated field. This calculated field will pull up the subcategories based on the selected category. Below we use an if statement to say if the category is equal to the category parameter then pull up the sub-categories, or else do nothing.
IF [Category] = [Category Parameter] THEN [Sub-Category] ELSE ' ' END
- Add the Calculated Field to the Rows Shelf
One you have created that calculated field drag it to your row shelf. At this point you should be able to click on any category bar and drill down.
BONUS!
- Adding Indicators
To add clarity to your chart you can add indicators to let the user know which fields can be drilled down and which field already is drilled down. As is seen by the black triangles in the image below.
To add these indicators create an if/else calculated field. Note, the indicators here are just copied from a character map, but you can use any symbol you desire.
IF [Category] = [Category Parameter] THEN '▼' ELSE '►' END
Add the calculated field to your row shelf.