#TipWeek: Bar-in-Bar Charts - Great for comparing two things

by Anuka Teggart

For my last tip of the week, I thought I’d teach you all how to create bar-in-bar charts i.e. a bar chart within another bar chart where one is fat and the other skinny (and different colours of course!). They are a really elegant way of comparing two things like your sales for this year compared to last year like below.

bar in bar

Let’s create the chart above showing sum of sales for the years 2011 and 2012 for each sub category using Sample – Superstore data (Tableau’s free example dataset).

 

  • First we must calculate sales for each subcategory for both years with two calculated fields.
  • So open up a new sheet and create a calculated field called ‘2011 Sales’ and type in the following:

IF YEAR([Order Date])=2011 THEN [Sales] ELSE NULL END

  • Do the same as above but substitute 2011 for 2012 and call that calculated field ‘2012 Sales’.
  • Drag Sub-Category to Rows
  • Drag 2011 Sales to Columns
  • Drag 2012 Sales to the point indicated in the gif below to create a shared axis with 2011 Sales

bar in bar 1

  • Drag ‘Measure Names’ off of Rows
  • Drag ‘Measure Names’ onto both Colour and Size

bar in bar 2

  • Go to Analysis on your toolbar then ‘Stack Marks’ then select ‘Off’
  • Voila, a bar-in-bar chart you can then format how you like

bar in bar 3

As always, thank you for reading.

Anuka