PTS Blog

Main menu:

PTS Utilities

Commercial Utilities developed by Peltier Technical Services

Waterfall Chart
Box and Whiskers


 

Excel Books

Books that I own and use while developing in Excel

Subscribe

Subscribe

Site search


Recent Posts

Recently Commented

Popular Posts

Archive


 

Categories


 

Buy me a coffee

If this topic or the blog itself has been helpful, why not support further development by treating me to coffee?


Privacy Policy

Creative Commons License
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Clustered-Stacked Bar Charts

by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.


This is a companion article to Clustered-Stacked Column Charts.

Excel offers clustered bar charts and stacked bar charts among its standard options.

Clustered Bar ChartStacked Bar Chart

A common request is to make a bar chart where the bars are clustered together, while one or more of the clustered bars are divided into sections stacked on top of each other. This isn’t built into Excel, but by rearranging the worksheet data, it can be constructed readily.

Suppose we have the simple data below, with four series of data over three months. One series is to be by itself in the top bar of the cluster, and three series stacked on the bottom.

Clustered Bar Chart Data

We can select this data and create a clustered bar chart

Clustered Bar Chart

or a stacked bar chart

Clustered Bar Chart

But however we try to arrange series, we cannot achieve a clustered-stacked bar chart.

If we keep our wits about us, we can envision a worksheet arrangement that will give us what we want. We need a gap, one series stacked in the first filled slot, three series stacked in the second slot, then another gap, and the pattern repeats. So this is really a stacked chart. Where we have gaps, the series have zero values; where one series is alone, the others have zero values; where the three series are stacked, the other has a zero. This new arrangement is shown below. Gaps in the data occur at columns B, E, H, and K. The left column of each cluster has data in columns C, F, and I; the right column in D, G, and J. For clarity in this exercise, I’ve duplicated the column letters in the category labels range (B7:K7, tan). The top left cell (A7) is blank.

Clustered Bar Chart Data

Select this range and create a stacked bar chart. It’s halfway done, we just need some formatting. To get the categories in top-down order, format the category (X) axis scale so that the categories are in reverse order and the value (Y) axis crosses at the maximum category.

Clustered Bar Chart

Change the gap width of any series to zero, and it looks almost done.

Clustered Bar Chart

The axis labels aren’t right, though. We need the months centered between existing labels, for example, “Alpha” between the current positions of “C” and “D”. This simple data works; note its arrangement parallels the original data. I’ve used 10 for the values so the bars show up in the charts. When I finish I’ll change the values to zero.

Clustered Bar Chart Data

Here is what the chart’s axis should look like when we’re done:

Clustered Bar Chart

Copy the data in F1:I2, select the chart, and use Paste Special to add the data as a new series, with data in rows, category labels in the first row (we’ll have to reapply this later), and series names in the first column. The data is stacked on top of the first three categories.

Clustered Bar Chart

What we need to do is put the axis series on the primary axis and the stacked data series onto the secondary axis (if we reverse this, we will have problems displaying the Alpha-Beta-Gamma axis labels). Select one of the series, and move it to the secondary axis. I usually move the lowest valued series first (Right 3 in this example) so that the secondary axis series don’t obscure the primary series I need to select and move next.

Clustered Bar Chart

In turn, select and move all of the Left and Right series to the secondary axis. I’ve changed the gap width of the Axis series to 50% (from zero) to make it easier to follow. The Left and Right series are clustered, not stacked, because that’s Excel’s default bar chart variation.

Clustered Bar Chart

Select one of the secondary axis series, and change its chart type to stacked. All bar series on that axis will follow suit. Also, change the gap width of a secondary axis series to zero.

Clustered Bar Chart

Excel has given us a secondary value (Y) axis, but we only have the primary category (X) axis. Using Chart menu > Chart Options > Axes tab, or in Excel 2007, the Chart Tools > Layout tab, to add the secondary axis to the chart. At first, we don’t have the appropriate names as our labels, because Excel applied the existing labels (B through K) to all series.

Clustered Bar Chart

Edit the series source data or the series formula for the Axis series, so that the months in G1:I1 are used for category labels.

Clustered Bar Chart

Almost done. The month names are not centered correctly next to the clustered bars. Format the scale of the secondary category axis (B through K at the right of the chart) so that the value axis does not cross between categories.

Clustered Bar Chart

Perfectly aligned. Now format the secondary category axis to display no tick labels and no tick marks.

Clustered Bar Chart

Use Chart menu > Chart Options > Axes tab or Ribbon > Chart Tools > Layout tab to remove the secondary value (Y) axis (or select it and press Delete). Format the Axis series on the secondary axis so that it has no fill. Change the Axis series values in G2:I2 from 10 to zero. Select the legend, then select the Axis legend entry, and hide it by pressing Delete.

Clustered Bar Chart

Not too complicated, and it shows exactly what we want.

Possibly Related Posts:

Bookmark and share this entry:
  • Digg
  • del.icio.us
  • Facebook
  • Technorati
  • TwitThis
  • StumbleUpon
  • Google
  • Reddit
  • MySpace
  • Slashdot
  • LinkedIn
  • Yahoo! Buzz

Comments

I welcome comments from my readers. If you have an opinion on this post, if you have a question or if there is anything to add, I want to hear from you. Whether you agree or disagree, please join the discussion.

Read the PTS Blog Comment Policy.


Comment from derek
Time: Monday, October 13, 2008, 2:06 pm

Allow me to shake my fist at the sky a bit and rage that none of this would be necessary if Excel just had a button to turn everything round X for Y, just as if it were viewed with head a-tilt, except for keeping labels horizontal and reconforming to the aspect ratio of the graph area. Dot plots, too, would become trivial instead of impressive exercises in Excel wizardry.

Curse you, Microsoft! (shakes fist)


Comment from Chris
Time: Thursday, October 30, 2008, 9:56 am

How might one go about adding a line chart onto the above clustered-stacked bar chart? I am trying to overlay data onto a stacked bar chart via several lines attempting to use the method outlined in “Clustered-Stacked-Column Combo Chart With Lines” discussion.

Thanks,

Chris


Comment from Jon Peltier
Time: Thursday, October 30, 2008, 10:47 am

Chris -

You have to add it as an XY chart series, but Excel won’t let you, at least not easily. Since you have bar series on both primary and secondary axes, and Excel doesn’t let a bar chart series share its axis group with any other type of series, there are no axis groups left to accommodate the XY series. You have to backtrack, and remove the bar series used for the vertical axis labels. With the bar series on the primary axis, you can put one or more XY series onto the secondary series. So add two, one for the line you want to show, and the other to serve as placeholders for the vertical axis labels. The two techniques you need are covered in Vertical Category Axis and Bar-Line Combination Chart, and when I have a moment I’ll write a new post that brings it together.

Write a comment





Subscribe without commenting

Create Excel dashboards quickly with Plug-N-Play reports.