26 Aug 2016

Visualising Olympics Data With Stacked Bar Charts in Tableau

Nicolas Voirin

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)

Tableau and Olympics: standard bar chart

Figure 1: standard bar chart

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").

Tableau and Olympics: stacked bar chart

Figure 2: stacked bar chart

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'

Tableau and Olympics:stacked bar chart with totals

Figure 3: stacked bar chart with totals

Job done!

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.

Tableau and Olympics: stacked area chart

Figure 4: stacked area chart

 

Nicolas Voirin

About the author

Nicolas Voirin - Graduate Analytics Consultant. I have started my career in the field of analytics because I have an interest in how data can be used to bring genuine value to organisations. With a background in Engineering and Management, I take pleasure in solving business problems and believe visualising data is a powerful tool to do this. I am curious about a range of topics but have previously enjoyed building data visualisations concerning politics and history.

Related to Visualising Olympics Data With Stacked Bar Charts in Tableau