Visualising Olympics Data With Stacked Bar Charts in Tableau
Tableau Desktop lets you build Stacked Bar Charts very easily. Stacked Bar Charts represent an effective medium to visualise proportions of a whole. Bar charts are already a very good way to visualise a certain measure across different dimensions, but stacked bars let you add another layer of information to your bars by breaking down the measures according to more dimensions.
Due to the Rio 2016 Summer Olympic Games just finishing, I decided to use the Summer Games with a focus on GB as my use case. The Stacked bars let us not only visualise a country's number of medals over time but also break down this number into gold, silver and bronze medals. Find my stacked bar dashboard ("Defining the odds: Team GB's success at Rio 2016") in the story I created around the Olympics:
Building the stacked bar chart:
1. Create a bar chart:
a. Drag the Date ('Year') field to Columns and your SUM(Number of Medals) to Rows
b. Drag SUM(Number of Medals) to Label in the marks card for clarity
c. (Optional): Add filters (in this case, Country: Great Britain)
2. Create your stacks:
a. Drag any dimension to Colour in the marks card, this will slice each bar by that dimension (in this case "Medal class").
3. The icing on the cake: Add totals to your stacked bars:
a. Duplicate your measure in Rows (Ctrl + click and drag to the right of it).
b. Right click the second measure and select 'Dual Axis' – this will plot the two charts on the same X axis.
c. Right click the right Y axis that has just appeared, and select 'Synchronise Axis' – this ensures that both Y axes are aligned.
d. In the marks card of the second measure you have just selected, remove the dimension slicer ("Medal class" in this case). This will revert to the standard bar chart total.
e. (Optional) If the second measure are covering up the first (thus hiding the slicing), right click the right Y axis and select 'Move marks to back'
Bonus: Stacked Area Charts
In your 'All' marks card, change the mark type from 'Bar' to 'Area'. As simple as that, you've created a stacked area chart.