Clustered-Stacked-Column Combo Chart With Lines
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
Excel offers clustered column charts and stacked column charts among its standard options.


A common request is for a clustered-stacked column chart where the columns are clustered together, while one or more of the clustered columns 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.
In Clustered-Stacked Column Charts I showed how to construct such a chart.

But now I’ve been asked to extend the combination to include a set of lines on the secondary vertical axis.

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

Following the rationale in Clustered-Stacked Column Charts, the data must be rearranged to the following format, so all of the columns will be positioned as desired.

Select this range and create a stacked column chart. It’s halfway done, we just need some formatting.

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

In Clustered-Stacked Column Charts, we used a dummy series to make the category axis labels look right. To add a set of lines which are cenetered on each cluster of columns, we will use the same approach. Here is the data for the line series. This simple data works; note its arrangement parallels the original data.

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

Copy the data in F1:I3, 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.

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

In turn, select and move all of the A and B column series to the secondary axis. The A and B series are clustered, not stacked, because that’s Excel’s default column chart variation.

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

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 month names as our labels, because Excel applied the existing labels (B through K) to all series.

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.

The stacked column Y axis (secondary) is along the right edge of the chart, and the line Y axis (primary) is along the left. We want to switch these axes. Format the secondary X axis (top) so that the Value Y Axis does not cross at the maximum category (uncheck the box). Then format the primary X axis (bottom) so that the Value Y Axis does cross at the maximum category (check the box).

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

Perfectly aligned. Now convert one of the line series from a column to to a line style.

Repeat for the other line series.

Now format the secondary category axis (B to K along the top of the chart) to display no tick labels and no tick marks. Adjust the plot area width so the legend does not obscure the Y axis labels.

You may want to reposition the legend.

This chart illustrates a problem with secondary axes, which Stephen Few wrote about in Dual-Scaled Axes in Graphs-Are They Ever the Best Solution?, and which I followed up in Secondary Axes in Charts. The problem is twofold. First, having the primary and secondary series overlapping in the same chart space makes it unclear which series corresponds to which axes. Second, it is impossible to separate the primary and secondary series visually. For example, although the lines and columns are independent, the red line seems to match with the green column at the endpoints but with the blue column in the middle.
These problems can be avoided by using two separate charts, or if you’re a bit more adventurous, by creating a panel chart.


Arranging the chart that way without changing its height shortens the vertical scales, reducing resolution of the axes. The legend can be moved and the chart made taller and narrower.

This illustrates a problem with chart legends. First, they force the reader to move his eyes between the charted data and the legend. Second, in this case, the legend is completely out of order compared to the plotted points. It is usually better to use data labels right in the chart.

Possibly Related Posts:
- Clustered-Stacked Bar Charts
- Clustered-Stacked Column Charts with Vertical Separators
- Clustered-Stacked Column Charts
- Clustered-Stacked Column Chart with Target Line
- Order of Legend Entries in Excel Charts
- New Series: You Asked For It
- Date Axis with Centered Years
- US Employment Slump Chart – How To
- Stacked Area Chart Challenge
- Add a Target Line
Posted: Thursday, August 7th, 2008 under Combination Charts.
Comments: 29
Comments
Comment from Bob
Time: Friday, August 8, 2008, 8:50 am
Jon,
I visit this site everyday. I am always amazed at what can be done with Excel charts.
Great tutorial.
Bob
Comment from Rick Williams
Time: Monday, August 11, 2008, 7:23 pm
I notice how you often place the series labels on the last data point of your series. I like the idea, and it always makes sense on the examples you describe, but usually when I try to do the same thing the effect isn’t the same; often the chart has too many datapoints or the endpoints are too close together. Do you have any guidelines on how you might best incorporate dataseries labels into a chart?
Comment from Jon Peltier
Time: Monday, August 11, 2008, 8:38 pm
Hi Rick -
Sounds like a topic for another entry. I haven’t codified my approach, there’s still a bit of art in it. I like to make the label text the same color as the markers or lines in a line or XY chart. I look for places in the chart where there is good separation between series, so labels are not cluttered and there is less chance for confusing which label goes with which points. Labeling the rightmost point in a series means usually there is room for the label to the right of the point.
I have a simple macro which automatically labels the last point of all series in a chart with the series name. I no longer use it myself, because it applies static text, and the label doesn’t change if I update the series name. It’s a simple fix which I may make someday (another blog topic!). Anyway, the simple macro can be found here:
Label Last Point
Comment from Jason
Time: Thursday, August 28, 2008, 10:16 am
Jon-
Thanks for this trick! Very cool! I used it today!! Great site!
-Jason
Comment from Amy
Time: Tuesday, September 23, 2008, 11:07 am
Hi!
I’ve been struggling through this and finally noticed one instruction that I seem to have been missing:
“The stacked column Y axis (secondary) is along the right edge of the chart, and the line Y axis (primary) is along the left. We want to switch these axes.”
My question is how do you do this? Am I going through and switching series’ axis from secondary to primary and vice versa?
I may be dense or just missing the obvious but would greatly appreciate the help.
Thanks,
Amy
Comment from Jon Peltier
Time: Thursday, September 25, 2008, 12:18 am
Amy -
The rest of the paragraph explains how to do this:
“Format the secondary X axis (top) so that the Value Y Axis does not cross at the maximum category (uncheck the box). Then format the primary X axis (bottom) so that the Value Y Axis does cross at the maximum category (check the box).”
To format the scale of an axis, select the axis, press CTRL+1 (numeral one) to open the dialog, and on the Scale tab (Excel 2003 & earlier) or on the first tab of Excel 2007 (I forget its name), check or uncheck the appropriate box.
Comment from Amy
Time: Thursday, September 25, 2008, 2:44 pm
Thanks Jon. For some reason, my axes weren’t flipping when I did that. They are now!! Go figure.
Thanks again,
Amy
Comment from Bridget
Time: Tuesday, November 25, 2008, 12:50 pm
Hi John,
Thanks for the post. I followed the Clustered-Stack Column Chart page, and generated a nice chart. However, now I want to add 6 more data series (which will all be lines, and on a different scale than the current axis for the bars). This applies to your above example, but with the following exception – the data series which I hope to add as lines to the bar chart does not parallel the bar chart data series. More specifically, the x-values for the bar chart are months (Jan, Feb, March, etc.), but the x-values for the line chart are daily (Jan 1, 2008; Jan 2, 2008; Jan 3, 2008; etc.). Is there a way to generate the chart, nevertheless, or do the x-values have to match? I know I could average the data for the month to make the data parallel with the bar chart, but I would rather have the daily variation visible in the line data series.
Thanks.
- Bridget
Comment from Jon Peltier
Time: Tuesday, November 25, 2008, 2:09 pm
Hi Bridget -
Most things are possible in Excel, you just need to know which preconceptions need to be broken.
However, there are a couple of issues with what you want to do:
First, the column clusters are positioned monthly with an equal space for each month. Plotting daily data on top of this results in an unequal space for each month because of the different numbers of days in each month.
Second, in general showing items on primary and secondary axes can lead to confusion, and showing the monthly columns and daily values on the same chart are likely to increase that confusion.
Because of these two issues, I’d think using two charts would be prudent.
Comment from Ben
Time: Tuesday, December 2, 2008, 4:57 pm
Hi Jon, I’ve followed all the necessary directions for creating a chart with stacked columns and lines. However, when I change the chart type to lines, they do not show. They will display the markers but no lines. Any idea why this might happen? I’m using Excel 2007.
Thanks,
Ben
Comment from Jon Peltier
Time: Tuesday, December 2, 2008, 5:36 pm
Ben -
Is the data for the lines contiguous as in my example of F1:I3, or sparse ike the column data in A7:whatever? If it is sparse, I suspect the problem is the setting for how Excel plots empty cells. By default, Excel doesn’t plot anything for a blank cell, so you’re seeing the gaps between populated cells. Select the chart, then go to Tools menu > Options > Charts and change the setting to Interpolate. Sometimes in a combination chart, you cannot set this property. Insetad you need to enter #N/A into the cells where you want the line to interpolate over.
Comment from Ben
Time: Tuesday, December 2, 2008, 7:08 pm
Jon, thank you for your very quick help. I couldn’t find the option to Interpolate. Fortunately by filling the empty cells with #N/A the lines filled in just as I was hoping. Thanks again for the solution and for developing this site.
Ben
Comment from Gordon Innes
Time: Tuesday, March 10, 2009, 3:33 pm
Hi Jon,
I am trying to create a clustered-stacked column chart with stacked data on the primary and a plain column on the secondary. I need to show two y-axes.
I have tried the method for the clustered stacked chart where both columns are against the same scaled y-axis for some of the other data presentation. This has worked fine. The problem I’m having is that to get both columns to show, I have to use dummy zero series on the secondary axis before the plain column and play with the gaps so that the two columns do not overlap. Adding dummy series on the primary axis doesn’t help me as they just seem to add zero values to the top of the stack!
This is not ideal as I have had to end up with very skinny columns with the primary stacked data centred on the x-axis label and the secondary plain column offset to the side.
Any clues on how I can construct the chart I am trying to achieve? Any help much appreciated.
Cheers,
Gordon
Comment from Jon Peltier
Time: Tuesday, March 10, 2009, 8:19 pm
As difficult as primary and secondary axes with clustered and stacked series are to display clearly, they are even more difficult to read and interpret. Charts with simple data and primary plus secondary axes are hard to read and interpret correctly without drawing false conclusions because of the arbitrary placement of the axis scales with respect to each other.
This is a case in which panel charts (e.g., Marimekko Replacement – 2 by 2 Panel) are superior.
With that warning, here are the mechanics that do what you want.
Starting with a familiar example, with the single bar to the right of the stacked bars. These are all on the secondary axis despite the series names, because the hidden series with the month names as category labels is plotted on the primary axis.

Here the original primary axis series has been removed, which pushes the other series to the primary axis, and there is no longer a secondary axis.

Now let’s use vastly different values for the Secondary series, so the series towers over the stacked primary series.

Assign the Secondary series to the secondary axis. It’s thin, because the default gap width is 150%. Also note that the secondary Y axis starts at 480, not at zero. This is a grievous sin for a column or bar chart.

I’ve now fixed the axis scale, and given primary and secondary series a gap width of 20%. Hopefully the separation may prevent the user from becoming too befuddled about which axis goes with which bars.

Here’s the data we need to put XY data points at the appropriate axis categories along the category axis.

Copy the left two columns of this range, select that chart, and use Paste Special to add the data as a new series with all of the appropriate options.

It’s not visible, because a column chart with zero values has no thickness. Change the added series to an XY series. It goes onto the secondary axis, but primary and secondary axis groups use the primary category (X) axis, and the data points align where we want them.

Use Rob Bovey’s Chart Labeler to add the labels of the third column in our added data range to the XY series as data labels. They are colored red here for clarity.

Hide the secondary axis tick labels and tick marks. You’ll probably have to adjust the height of the plot area to give room for the added labels below the axis.

Finally hide the XY series by formatting it with no lines and no markers. Remove the legend entry for the Axis series: two single clicks to select the legend entry (the label not the marker) and press Delete. Finally, if you copied too closely and made the added labels red, make them black again.

Comment from Gordon Innes
Time: Wednesday, March 11, 2009, 6:33 pm
Jon,
Many thanks for your very prompt feedback – I’ll recut the charts tomorrow. I also note your comments about the perils of side by side data on two axes – will be sure to try the panel charts as an alternative.
Your site is excellent – really has saved me from hours of expletives and pulling out of hair!
Thanks again.
Comment from Mona
Time: Friday, April 10, 2009, 2:32 pm
I have tried creating this chart and just the clustered stacked column charts and I keep having issues with the x axis. My bars stay stacked on top of the first few categories even when I add the secondary axis and switch the stacked column series (the ones that are supposed to stay bars) to it. Please let me know what I am missing
Comment from Jon Peltier
Time: Friday, April 10, 2009, 4:47 pm
The primary series (that produces the visible labels along the bottom) must use a smaller range of category labels than the stacked columns. In my example, the stacked columns use B through K (10 columns), while the labels use G, H, and I (three columns). You may have to go to the source data dialog and adjust this, especially if you are using Excel 2007.
Comment from Mona
Time: Tuesday, April 14, 2009, 2:51 pm
Is there any way around this? I am trying to create the following charts
1. 12 dates on the primary axis, 6 stacked columns(for a total of 3 bars), with 3 lines
2. 26 names on the primary axis with 6 stacked columns
you can think of me charting the following type of data
1. number of large/small (stacked) ice creams purchase over the past three years for each month (12 months on primary axis)..lines would be cumulative data for each year
2. types of ice cream on primary axis with the number of small/large (stacked) per year represented in columns
any other suggestions on how to better display this data?
Comment from Jon Peltier
Time: Tuesday, April 14, 2009, 4:07 pm
Mona -
It sounds like you’re trying to plot two charts worth of different data in one chart. The line charts with monthly counts of large and small ice creams sold is easy enough (or would you want to show revenues?).
For the types of ice cream, if you are only plotting it annually, I would make a clustered column chart, one column per flavor, and the value would be the revenues of each. You could stack # of large and # of small, but then, the large servings count for more, so do you scale hte bars? That’s why I think revenue is easier to show.
If the number of each size and flavor is important, then you oculd show your initial charts as I’ve described, then create more charts showing numbers of each subcategory instead of revenues.
Comment from Enekhai Henry
Time: Wednesday, April 15, 2009, 9:54 am
I followed your instruction and was successful at creating a clustered colum chart with line series.
I intend to use this chart as a template for other charts. What I did was to copy the chart and change the source data to a different one (which has been previously arranged as instructed). But each time I did this, I found out it became necessary to use two vertical axis. Trying to correct this created problems of all sorts. Been trying to do this for sometime now.
Will appreciate your help.
Comment from Jon Peltier
Time: Wednesday, April 15, 2009, 10:39 am
I’m not sure how you’re changing the links. The easiest way to handle this is to make an exact copy of the chart and its worksheet, and then replace the old data with the new data. This avoids the need to actually change any links.
This and related approaches are discussed in Make a Copied Chart Link to New Data.
Comment from John
Time: Monday, July 13, 2009, 7:48 pm
Is there a way for *each* stack to have its own set of lines? Moreover, let’s say each stack has respective high and low data. Typically, I would do 2 lines series per stack (remove the line and add high-low bars), but I’m having a bit of difficulty doing it for clustered stacks. Any suggestions?
Comment from Jon Peltier
Time: Monday, July 13, 2009, 9:28 pm
John -
The line series would use the same X values as the columns, not as the overall clusters. The line data must be staggered to match the column data, so the markers line up with the columns. Start with this data:

Start by creating a line chart, and use the option to interpolate over blank cells (otherwise there will be no lines connecting the markers).

Change A, B1, B2, and B3 to stacked column type series.

Move the line series to the secondary axis, and apply various formatting as in the chart above. Note: another XY series is used to provide the month labels along the bottom of the chart.

Here is an alternative arrangement for the chart:

Comment from Yuki
Time: Wednesday, July 22, 2009, 4:25 am
I can create 2 stacked column as mentioned by above. But I tried many ways, just couldn’t add a line graph to create 2 stacked column + 1 line. How to do it?
Comment from Jon Peltier
Time: Wednesday, July 22, 2009, 9:24 am
When the series is added, it is added as another stacked column on top of the others. You can’t make it a line type series until after it is created as a stacked column.
Comment from MMS
Time: Tuesday, August 4, 2009, 10:42 pm
You saved my life twice . Had to create clustered stacked charts for my management and then after 4 months needed to add a line to it . Thank you so much !!!
Great job!!!
Comment from Hannah
Time: Tuesday, August 18, 2009, 3:34 pm
Brilliant, this was easy to follow and worked beautifully. Thanks so much! You saved me a lot of time and trouble.
Comment from Choco
Time: Thursday, October 22, 2009, 8:43 am
Jon,
Thank you so much for this great material – will be using this over and over. One question: Is there a way one could add totals to all the stacked/clusteres columns? That would really help. I hope this is not too dumb of a question….
Comment from Jon Peltier
Time: Thursday, October 22, 2009, 9:25 am
Looks like another entry for “You Asked For It”. Stay tuned.
















Write a comment
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.
If you want to include an image in your comment, post it on your own site or on one of the many free image sharing sites, and include a link in your comment. I'll download your image and insert the necessary html to display the image inline.
Read the PTS Blog Comment Policy.