This is one of those “simple” things that is a bit confusing at first. In general I complain when people use stacked bars, because I see them as horizonal/vertical pie charts. And the pie chart is that universal point of contention between data analysts. Some people claim it’s the best visual tool for easy comparison, and other people claim it’s one of the worst tools. You can count me in the “never use it” camp. I won’t attempt to go into why on my soap box, but my general advice is that if you have to use it then never use it with something requiring more than two “slices”. The same applies for stacked bars.

However – a great use for stacked bars is when you display them as you would a “progress bar”. I.E. each bar fills up complete space and is out of 100% (a bit different than a bullet chart if you are familiar). There are two ways to go about it – either with a single measure (you have a dimension to split the data up), or with multiple (this tends to trip people up).

Using a Single Measure

Tableau has a KB article explaining how to do a basic viz here, but I think it’s a bit unrealistic. Below is a small real-world example that I’ve used in the industry. Imagine if I want to track how users are printing across my network. In general I have Color or Black and White printing, and there is a significant cost savings for an enterprise to reduce color printing where possible. The table is a sample of 10 rows.

Add the pages to the columns as a table calculation – creating a quick percent of total. In addition, move your printType to Color (to split it up), and printDate to rows. That’s about it!

If things aren’t looking right then it’s generally because you need to alter the Table calc direction (Compute Using).

Using Multiple Measures

To keep a baseline here, I’m going to use the same dataset – but I’m going to force Color and B&W into two separate measures. In other words, I’m going to pretend that I don’t have a printType to split them on Color By. There are many times where you’re data may be formatted in this manner (pivoted to columns instead of rows).

Now that we have separate measures for both – we need to manually create the percentage that we relied on the Table Calculations for.

--B&W Pages
sum([B&W Pages]) / (sum([B&W Pages]) + sum([Color Pages]))

--Color Pages
sum([Color Pages]) / (sum([B&W Pages]) + sum([Color Pages]))

Now we are going to use the magic of Measure Names and Measure Values. Add Names to Columns and to Color By. You will need to filter the Names to include only the two measures you wish to display. With a little formatting, you now have the same results!

For a copy of the workbook I used please download here