The Best Alternative to Stacked Bar Charts I've Ever Seen! (with Sebastine Amede & Darragh Murray)


 

The following is a collaborative blog post from Sebastine Amede, Darragh Murray, and me. 


Sebastine Amede is based in Abuja Nigeria where he works as a freelance Data analyst. Sebastine was a Tableau featured author in 2024 and among the Tableau Rising Stars this year. He uses Tableau to explore creative ways to visualize data in the business world. 

Darragh Murray is a senior analytics and insights specialist based in Brisbane, Australia, working in the energy transmission sector. He’s a three-time Tableau Ambassador and a two-time top 10 finisher in the IronViz feeder competition. Passionate about data visualisation and storytelling, Darragh regularly explores topics like music, history, and Australian Rules Football using tools like Tableau and R—and loves writing about the journey along the way.



In Kevin's words:

I don't love stacked bar charts. Okay okay okay...I hate stacked bar charts. There are simply so many problems in reading and understanding them. You can easily compare the grand total of the bars. You can also easily compare the segment that is aligned to the axis. But when you try to compare other segments that are not aligned to an axis, this becomes very very difficult. 

Several people, including myself, have historically found ways to improve upon the stacked bar chart. One method, created by Steve Wexler and improved upon by Ryan Sleeper using parameter and/or set actions, is to allow the end user to choose which segment (or segments) are aligned to the axis therefore allowing for better comparisons of those segments. Check out Steve's technique here and Ryan's technique here.

Another method that I typically use is to completely unstack the bars then, using a Tableau hack, I add grand total stacked bar. I also give the user the ability to view the unstacked segments on a uniform or independent axis. Check out my technique here.

Generally speaking, every time I see a stacked bar chart, I desire to change it to something that is easier to read.



A New Chart?

I was recently scrolling through LinkedIn and saw a post from Sebastine Amede where he utilized a technique from Brittany Rosenau and applied it in such an incredible way that he could have possibly solved all the problems with stacked bar charts!  Possibly. Here is a snapshot of his visualization.



So, what we see here is a large gray bar that shows the grand total for each region. Then within the gray bar, we have the individual segments (the actual Segment field in Superstore) in green, orange, and blue (consumer, corporate, and home office respectively). In a stacked bar chart, these individual bars segments would be stacked up to make the total. However, in this case, they are unstacked. This allows us to compare segments values within a region. For example, we can compare consumer, corporate, and home office within the East region. We can compare individual segments across regions, i.e. we can compare the consumer segment across the West, East, Central and South. We can compare the total.  In fact, because they are all aligned to the axis, we can compare anything we want - segments, totals, everything!

Does this completely solve the stacked bar problem? I hate to say definitively YES, but it sure seems to solve most of the issues. I think the major problem with this chart is that it's new.  I mean, yes...perhaps someone or several someones in the past have created something similar to this (if you have, let me know so I can credit you), but generally speaking, this is not a common chart. So if you create this, you're going to have to explain to end-users how to read it. But with a bit of education, I think this chart is FAR SUPERIOR to its stacked bar counterpart.


How to Build It?

After I saw what Sabastine had created, I decided to take a crack at it myself to see if I could build a version of it (without downloading his). In doing so, I created my own version of the chart using a slightly different technique. Mine looks like the following:



I then started doing a bit more research and found that Darragh Murray had historically created a version of this chart too. His looked like the following:




So I asked both Sebastine and Darragh if they would write up their techniques to share in this blog post. Below, I've included three techniques (including my own) to building these alternative to stacked bar charts in Tableau.

But before we do...I'm kind of sick of calling this chart "the unstacked alternative to stacked bar charts", so we really need a name for it. Let's call it the "Segmented Total Bar Chart".

Each of these will use Superstore data and will be visualizing Sales by Region sliced by Segment. As a starting point, I've created a standard stacked bar using this data.



Sebastine Amede

In Sebastine's words:

One thing I have always disliked about stacked bar charts is their difficulty to read. Not only that, but it's nearly impossible to compare measures across all dimensions. There has to be a substitute for this. 

A few weeks ago, I came across Brittney's work, where she overlaid two bar charts, one for the current year's value and the other for the previous year's value. This not only looked aesthetically appealing but also allowed for easy comparison between the two years. That was the inspiration for my stacked bar chart substitution. I also remembered an infographic I had stumbled upon in the past, where they had multiple bars inside individual bars (unfortunately, I cannot recall where I had seen it). Using Brittney's technique and the infographic picture in my head, I started building. The resulting chart offers several advantages over stacked bars: it makes it easier to compare the sales performance of different segments within each region, and it provides a clearer visual representation of the relative contribution of each segment to the overall regional sales. 

Okay, let's build it.

Create a calculated field called "Index" with the following calculation: INDEX().

Drag the "Region" field to the Columns shelf. Drag "Sales" to the Rows shelf twice to create two Marks cards, and make them a dual axis. Synchronize the axis. In the second Marks card, add "Segment" to the Color section. At this point, it should look like the following:




Next, drag the "Index" calculated field to the Columns shelf. Right-click on "Index" and select "Compute Using" > "Segment."  In the Marks card that controls the gray "Region" bars, click on "Size." Set the size to "Fixed" and type in 6, then align to center using the options at the bottom of this window. Depending on how many sub-categories you have, you may need to make the outer bars bigger. As a rule of thumb, if you have a maximum of 3 sub-categories, the outer bar's size should be 3 multiplied by 2. This ensures that the outer bars can accommodate the inner bars.  Next, set the color of those bars to a light gray. It should now look like the following:





To create the overlap for the inner bars, click on "Size," choose "Fixed," and type in 1.5. Adjust the alignment (I set it to "Right" in this example). Lastly, adjust the opacity of the colored Segment bars to show the overlap. And with a bit of cleanup, here is the end result:



These are the basic steps, but depending on your creativity and goals, you can experiment with sizing, colors, borders, and axes to achieve your desired outcome. 



Darragh Murray

In Darragh's words:

Firstly, it’s a great personal honour to be invited by the Flerlage Twins to contribute to their blog – a publication I’ve turned to countless times throughout my own Tableau journey. I’m genuinely humbled that something I’ve created is considered worthy of sharing with the wider Tableau #datafam.

Secondly, I want to acknowledge the sheer coolness of Sebastine’s approach to the ungrouped stacked bar chart challenge. Aesthetically, I probably prefer his method over the very simple alternative I’m going to walk through here.

But hey, I’ll share my method anyway—just in case it proves useful to someone down the track.

Like many others, I’ve never been a huge fan of stacked bar charts. Mostly because I find it difficult to compare the individual components within each larger bar. Stacked bars often lack the precision I look for when producing—or consuming—data visualisation.

While planning a visualisation to show the causes of death during the Gallipoli campaign in World War I (a defining event in Australian history), I also wanted to convey the total number of fatalities. That led me to create The Lost Australians of Gallipoli, which breaks down fatalities into three categories (KIA, wounding, disease), while also communicating the overall volume across different stages of the campaign.

As you’ll see, this unpacks a stacked bar chart into its components while still giving viewers a sense of the total. The approach in Tableau is very simple—though fundamentally different from Sebastine’s method. It relies on a bit of reference line manipulation and some formatting tricks to achieve the effect.

Here’s a step-by-step guide using the standard Superstore dataset, where I’ll recreate Sebastine’s approach as closely as possible. You can follow along using my viz on Tableau Public.

First, bring sum of sales to rows and region and segment to columns. Sort your region dimension by total sales, so that the regions are arranged in descending order. Finally drag segment to the colour mark and colour accordingly.



Go to the analytics pane and drag a reference line to the canvas. Add it at the pane scope level. You now need to configure the reference line, so the line essentially returns the total of the sum of sales at a region level rather than a segment. It’s as easy as simply setting the line value to the sum of sales and changing the aggregation to ‘total’.
 
Because the scope is set at the ‘per pane’ level, the reference line will simply return a total of sales for that region..
 
Then you need to create the ‘bar’ effect by setting the fill below formatting option to suitable shade. I’ve just used grey in my example.




You might also want to change the label and tooltips to something useful like value so you can read what the total sales by region is on the resultant visualisation. You’ll start to see that it’s coming together now!




With some formatting of the chart, you certainly can clean it up to make it look even nicer. For example, dropping the gridlines, changing the column borders to something a bit more subtle (I used a very thin dotted line instead of the usual solid line), and fixing up number formats so the canvas looks a bit cleaner.




As I mentioned above, this embarrassingly simple approach isn’t the same as Sebastine’s but arguably achieves a similar outcome. 
 
One thing that I haven’t been able to easily replicate is using the region on the reference line label as you’re limited to only a small number of options (value, computation and custom).  But I think I prefer to run with the sum of sales anyway and use the field headers to show the region. 
 
And that’s it! This is fairly easy to implement, something Tableau beginners could pick up quite easily and run with, but perhaps may not have been aware of this visual approach. 
 
Thanks for reading and thanks again to the Flerlage twins for the opportunity.





Kevin Flerlage

In Kevin's words:

In order to create my version, start by creating a grouped bar chart with Region and Segment on Columns, SUM(Sales) on Rows, Segment on Color, and SUM(Sales) on the label (see below).


I want to create some spacing, so I'm going to utilize the sub-totals trick which you can read about in #8 of this blog post. You'll now have this:




We now have the individual segments we need, so now we need to create the gray, total bar. I'm going to cheat a little bit and just show a single gray bar behind each segment - which means 3 gray bars for each region. Then I'll increase the size of these 3 bars to be as large as possible so that they look like one big gray bar.  To create this, we need one calculation:

WINDOW_SUM(SUM([Sales]))

Add this to Rows then edit the table calculation and set it as shown in the screenshot below (which essentially says, for every Region, give me the sum of sales).  




On the Window_SUM axis, remove Segment from color and SUM(Sales) from label. Change the color of the bars to a light gray, remove any borders from the bars, and make them as large as possible. It should now look like the following:




You'll have to once again implement the spacing trick using subtotals (as detailed above) on the gray bars.  Now create a dual axis and synchronize the axes. Note that you may need to swap the position of the two measures on Rows so that the segment bars are on top and showing:




In order to properly label the gray bar, I chose to simply label the middle of the three gray bars - Corporate. I hardcoded in the Segment to label, but your situation may require a more dynamic approach (we could label the min, the max, etc.)  For now, I just created a calc to label the Region and Window_Sum as follows:

REGION LABEL
IF [Segment] = 'Corporate' THEN [Region]
ELSE NULL
END

SALES LABLE
IF min([Segment]) = 'Corporate' THEN [Window_Sum]
ELSE NULL
END

I then placed those on the gray bar.  With a little cleanup, here is the result:




In Kevin's words: 

And there you have it! Three different methods to creating this Segmented Total Bar Chart. Thanks so much to Sebastine and Darragh for writing up their techniques...and really for innovating this chart. And thanks so much to Brittany for the inspiration.

We'd love to know what you think of this chart. Let us know in the comments.







Need help with anything related to Tableau?  Through Moxy Analytics, Ken and I provide consulting services such as Tableau Lifeline (get us for 1 hour to help solve a sticky problem), Fractional Data Hero (get us on your team for N number of hours a month for whatever you want us for), Tableau & Dataviz Training, and of course, project work. Click the Icon below if you are interested.



Kevin Flerlage

April, 7, 2025

Twitter LinkedIn Tableau Public




1 comment:

  1. Liking the alternative and will be using it.

    ReplyDelete

Powered by Blogger.