Alternative to Hierarchies in Tableau.
How to mimic hierarchical (‘+’ / ‘-‘) action on your tableau dashboard without actually using hierarchies
“Design is not just what it looks like and feels like. Design is how it works.”— Steve Jobs
In the reporting world, you would often come across situations wherein the stakeholders would request for features or functionality not directly available in Tableau.
One such use case I came across was having a table expand and collapse on a click, more like having a hidden sheet show up when clicked on its parent table. (for folks who are familiar with Tableau, it’s just like clicking on a ‘+’ and ‘-‘ action of a hierarchy, but without using it). I’ll walk through the steps below on how I achieved that-
Note: I’m using the sample superstore data.
Step 1 — Create the view you wish to make clickable
This sheet should be the view you would want to click and have the expandable view shown up.
I’ve created a simple table to see what profits have been like over the years in ‘Consumer’ segment.
Step 2 — Create the expandable/collapsible sheets
The next step is to create the sheet, you would want to see when you click on the clickable view we created in the previous step.
Below is the expandable sheet I created for my use case, wherein we see profits over time across subcategories, filtered on segment — ‘Consumer’.
Step 3 — Create links between Clickable and collapsible sheets
The next step is to create links between our clickable and collapsible sheets. In any of the two sheets, create a calculated field like below.
Step 4 — Add the ‘Link’ calculated field in both sheets.
Add the ‘Link; calculated field in the rows shelf on both the sheets.
The next step is to hide the “Link” calculated field from both the sheets by clicking on the dropdown of the “Link” pill and unselecting ‘Show Header’ as below:
Step 5 — Pull the clickable and collapsible sheets onto a dashboard
The next step is to drag the clickable sheet on the dashboard in a container as below:
Next, drag the collapsible sheet right below the clickable sheet view in the same container.
Next are some formatting changes to make the clickable action look effortless.
First, hide the sheet title -
Secondly, fit the width of both the sheets as below:
Step 6 — Setting the expand/collapse action
First, you need to set up a dashboard action, by clicking on the dashboard in the menu bar.
Choose a filter action, with the source sheet being the ‘Clickable sheet’ and the target sheet being “Collapsible sheet”.
Make sure to select the ‘Run action on’ to ‘Select’ and the ‘Clearing the selection’ to ‘Exclude all values’.
One important thing is to choose ‘Selected Fields’ in the ‘Target Filters’ at the bottom of the dialog box -
Selecting the ‘Selected Fields’ will open up the below prompt. We would be selecting the ‘Link’ calculated field in both the ‘Source’ and ‘target’ fields. This way we would be linking the clickable and collapsible sheets.
Step 7 — Final checks
Once all the above steps are successfully executed, it's time to check if our dashboard actions work.
On the dashboard, clicking on the clickable sheet should collapse or hide the collapsible sheet.
Clicking on the clickable sheet again would show up the collapsible sheet, mimicking the “+” and “-“actions of a hierarchy.
You can find and download the above dashboard with the collapsible table from my Tableau Public profile.
Stay tuned for more such articles in and around data!