The Data School Down Under continues to give us plenty of challenges on many different levels. This time I chose to blog about one trick that I found very useful. It involves the most frequently used type of chart – a bar chart, and adds more complexity through using the stacked option, dual axis and labels. I thought adding a Total label to a stacked bar is a thing you can do with one click in Tableau, but since we still don’t have that option, here is a quick workaround.

I will use a table with Alteryx challenges which you can find on their previous blog post.

 

1) Creating a simple Bar-chart:

First, we need to build simple bar chart. Drag to the Rows shelf the dimension from your data source that you want to be used as header for the rows (in our case Main Subject). Then drag the measure/dimension that you want to be represented with bars onto the Columns shelf (in our case that is Challenge name). If it is a dimension, you will need to change it to a measure so that it can be represented with bars, therefore we changed ours to Count of Challenge name. Now we get a bar chart that shows how many challenges there are for each subject category. If you don’t get your bar chart instantly, go to show me and choose the right visualisation.

2) Creating Stacked bars

Next, drag onto color the dimension that should create your stacked bars (in our case that’s the Level of difficulty). Then go to Labels on the Marks card and tick the Show mark labels box. At the end – sort the bars by what makes sense to you so that it looks more organized (our case – Challenge name).

 

Note that you can’t see the totals yet, which means we have couple of additional steps. Our approach here is creating dual axis. Press Ctrl and drag the measure you already have on the column shelf to the right. Now you should get two identical bar charts one next to each other.

3) Adding Totals to Stacked Bar-chart

On the Marks card, go to the last card which has the name of the measure we just duplicated. Take whichever measure/dimension you had on color (in our case Level of difficulty). Next add Labels from the same Marks card (same as we did before). Make sure you have chosen proper color, so that you can see the marks. In my case, Tableau copied the formatting from the previous card (which was white font), so I had to change it to black in order to be visible on the white background.

  

What we have left now is to layer the two graphs we created. Go to the Columns shelf, right click on the duplicated measure and choose Dual axis. Note that Tableau will automatically change the marks to circle, so you have to switch them back to bars. Go to the Marks cards, choose the one labeled with “All” and from the drop-down menu choose Bar. Now your colorful bar is in the back and the bar with the total labels in front, which means you have to reorder them. Go to the Column shelf, drag the duplicated measure and position it before the original one. Make sure to synchronize the axis by right clicking one of them and choosing Synchronize axis. Do some additional formatting if you like, and Boom! – you finally have your stacked bar chart with totals.