This is a Quick Tip on how to build a Pyramid Step Chart in Tableau, so less reading and more jumping in. We are going to spend 5 minutes or less building our Pyramid Step Chart in Tableau.
Note: As always never choose a data visualisation type and try to fit your data into it, instead, understand your data and choose the best visualization for your data consumers.
Data
Load the following data into Tableau Desktop / Public.
Country,Path,Value
United States,1,0.8
United States,101,0.8
United Kingdom,1,0.67
United Kingdom,101,0.67
France,1,0.4
France,101,0.4
Germany,1,0.5
Germany,101,0.5
Japan,1,0.9
Japan,101,0.9
Note: we require path and duplicate lines for densification. See our tutorial on Data Densification for more information. Click here
Calculations
We will start by creating the following calculated fields.
Path (bin)
- Right-click on Path
- Go to Create, and select Bins…
- In the Edit Bins window:
- Set New field name to Path (bin).
- Set Size of bins to 10.
- Click OK.
Index
INDEX()
TC_Value
WINDOW_MAX(MAX([Value]))
Color
IF [Index] > WINDOW_MAX([Index])*(1-[TC_Value]) THEN
IF [TC_Value] > 0.8 THEN
"Green"
ELSEIF [TC_Value] < 0.5 THEN
"Red"
ELSE
"Orange"
END
ELSE
"Grey"
END
Worksheet
Now that we have created our Calculated Fields, we will build our Worksheet.
- Change the Mark Type to Bar.
- Drag Country onto Columns.
- Drag Path (bin) onto Rows.
- Right-click on the object and ensure that Show Missing Values is check.
- Drag Index onto Columns.
- Right-click on the object, to go Compute Using and select Path (bin).
- Drag Color onto the Color Mark.
- Right-click on the object, to go Compute Using and select Path (bin).
- Right-click on the object and select Edit Table Calculation.
- With Nested Calculation set to Color, select Specific Dimensions.
- Select both Country and Path (bin) and ensure that Country is on top.
- Set Restarting every to Country.
If all goes well, you should have the following:
Now we will adjust the cosmetics:
- Hide the headers.
- Set Row Divider to None.
- Set Column Divider to None.
- Set Zero Line to None.
- Set Grid Lines to None.
- Edit the Colors.
We are almost there, we have a half pyramid and should have something like the following:
Now we have the following final touches.
- Drag Value to Columns between Country and Index.
- Right-click on this object and set this to Discrete and Dimension.
- Format this to a percentage.
- Keep your finger on Ctrl, and left-click on Index and Drag to right and let it go, this will copy the Index Pill. This is a real time-saver.
- Now the final touch will be to double-click on the left Index Pill, add a minus sign to the left; this is an example of inline manipulation.
You should now see the following:
and boom, we are done, nice, simple and quick. You find my Pyramid Step Chart Dashboard on Tableau Public at
https://public.tableau.com/profile/toan.hoang#!/vizhome/PyramidStepCharts/PyramidStepChart
Summary
I hope you all enjoyed this article as much as I enjoyed writing it. Do let me know if you experienced any issues recreating this Visualisation, and as always, please leave a comment below or reach out to me on Twitter @Tableau_Magic.
If you like our work, do consider supporting us on Patreon, and for supporting us, we will give you early access to tutorials, exclusive videos, as well as access to current and future courses on Udemy:
- Patreon: https://www.patreon.com/tableaumagic
Also, do be sure to check out our various courses:
- Creating Bespoke Data Visualizations (Udemy)
- Introduction to Tableau (Online Instructor-Led)
- Advanced Calculations (Online Instructor-Led)
- Creating Bespoke Data Visualizations (Online Instructor-Led)