Hide Series Data Label if Value is Zero
by Jon Peltier
Tuesday, May 12th, 2009
Peltier Technical Services, Inc., Copyright © 2012.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
With a little knowledge of number formats and a healthy dose of creativity, you can work around apparent shortcomings in Excel’s charting mechanism, neaten up your charts, and produce effects that are otherwise difficult.
In the Microsoft newsgroup, someone asked how to hide the data labels in his stacked column chart if the values are zero.
The problem is, a stacked column data point with a zero value has height of zero, and the label sits on the boundary between the two points on either side. In the example below, the labels for series C are fine, but the labels for series B in the Beta stack and for series A in the Alpha stack have no points to label.

The trick is to use the value option for the data labels, rather than the series name option. The series names have been replaced by values, and zeros appear where the unwanted series name labels are in the chart above.

Then apply custom number formats to show only the appropriate labels. In Number Formats in Excel I show how the number format provides formats for positive, negative, and zero values, and for text, with the individual formats separated by semicolons:
<positive>;<negative>;<zero>;<text>
Apply the following three number formats to the three sets of value data labels:
"A";;; "B";;; "C";;;
What these formats do is use the characters in quotes in place of any positive numbers, and use “” (from between the semicolons) for negatives, zeros, and text. The undesired labels are now gone. The labels in the number format strings can be longer than a single character, of course; A, B, and C were easy labels to use for this illustration.

Related Posts:
- Label Totals on Stacked Column Charts
- Label Each Series in a Chart
- Easy Two-Panel Line Chart in Excel
- Growth Rates in a Panel Chart
- Easy Two-Panel Column Chart in Excel
- Area Chart – Invert if Negative
Posted: Tuesday, May 12th, 2009 under Formatting.
Comments: 22
Comments
Comment from DMurphy
Time: Tuesday, May 12, 2009, 7:36 am
It never ceases to amaze me how Excel can be twisted to do the (near) impossible! I have always said that programming (and I include spreadsheet manipulation in this definition) is more of an art than a science.
That was well worth a coffee! Enjoy with my thanks as this solves yet another of my users’ complaints!
Comment from Jon Peltier
Time: Tuesday, May 12, 2009, 8:13 am
Thanks, David!
I can usually get Excel to do whatever I want. Sometimes it takes unexpected measures, and sometimes a few off-color words.
Comment from ron
Time: Friday, January 8, 2010, 2:43 pm
in a similar vein, i’m using Excel data in a Powerpoint BAR chart (not stacked). however if the value of a series is ZERO i would like bar chart to ignore it. no label, no bar, no empty space where bar would be. can i do that?
Comment from Jon Peltier
Time: Saturday, January 9, 2010, 7:38 pm
It’s a bit complicated. If the data is in columns, you could hide the rows with zero or blank data and it won’t plot, because by default Excel doesn’t plot data in hidden cells. If it’s not as easy, it takes more involved manipulation of the data. I believe Andy Pope has some example on his web site, at http://andypope.info.
Comment from Paul Makulski
Time: Tuesday, May 4, 2010, 3:22 pm
I’ve been doing the same battle with a donut chart. The inner ring includes all of the outer ring labels stacked on top of each other at the zero position, and the outer ring has all of the inner ring labels stacked up. Really gross.
Your solution would work for this, except I’d need a custom number format for each cell (and there are going to be a lot of them).
There’s no way to set these formats using a formula, ist there? Or a conditional format (which for some reason doesn’t include number formatting.)
I also tried diddling the series formula, but it seems the “x” range is the same for all series, even when you specificly change them in the series formula.
I’m boxed.
Comment from Jon Peltier
Time: Wednesday, May 5, 2010, 6:27 am
Paul -
Why do you need so many custom formats? Select all cells and apply the same format.
Could you use any better chart type than a donut?
Comment from Paul Makulski
Time: Wednesday, May 5, 2010, 9:00 am
Hi Jon,
I have never used a donut before, but it was exactly what the user wanted.
To apply your number format solution, you need one custom format for each value cell to make it look like a label. There will be about 80 data points.
I have written a macro to do the custom formats for me. It works, but it really says “kludge”. (email me if you’d like to see what I’m doing.)
It would certainly be easier if Excel just provided for an option for a label range for each series. Do you know if that is a feature in Excel 7? (I’m using 2003)
Comment from Jon Peltier
Time: Wednesday, May 5, 2010, 10:42 am
Paul -
Excel does not provide a label range for its chart series (although Lotus 1-2-3 had it long ago).
Chandoo explains how to manually link up labels to worksheet cells in How to Change Excel Chart Data Labels to Custom Values.
And a clever Excel developer named Rob Bovey wrote an add-in which does the trick for you. it’s a free add-in available from his web site. Go to http://appspro.com and look for the Chart Labeler.
Comment from Jon Peltier
Time: Wednesday, May 5, 2010, 10:54 am
I questioned Paul about his use of a donut chart. He says it’s what the customer wanted to use to show relationships qualitatively:

This use of a donut chart is probably fine, since we don’t care about the areas of the arcs.
Comment from Rishu
Time: Friday, May 7, 2010, 3:25 am
Hi,
I am showing both the label and the value in my chart. For example, in my chart it would appear (A,3), (B,0) & (C,3) for Beta.
However, I want only (A,3) & (C,3) to appear.
Is it possible to do that? Basically for ZERO value, I neither want the label nor the value to appear.
Please help
Rishu
Comment from Jon Peltier
Time: Friday, May 7, 2010, 7:57 am
You can hide the zero value using a custom number format that suppresses zeros. However, the category will still appear, and it will look like ‘B,’.
Comment from Rishu
Time: Sunday, May 9, 2010, 7:52 pm
Hi Jon,
Yea currently I am doing that but because I have a lot of series and for a particular data points, only a few have values. This causes all the labels with zero values to overlap each other and hence the figure looks clumsy.
Is there any way to get rid of the label also as in I dont want the “B” to appear?
Thanks
Rishu
Comment from Jon Peltier
Time: Sunday, May 9, 2010, 8:52 pm
Rishu -
You could set up custom labels in another range of cells, with formulas that show “B” if the value is not zero, and “” if the value is zero. Link the labels to these cells manually (select the set of labels with one click and the individual label with another click, type = in the formula bar, click on the cell with the label, and press Enter) or using the Chart Labeler by Rob Bovey of AppsPro.com.
Comment from Amber Criner
Time: Thursday, July 8, 2010, 11:21 am
I put in the custom number format as #;;; and it worked like a charm to get rid of the zeros.
Comment from Leo Franklin
Time: Monday, August 16, 2010, 6:43 am
hi its not complicated ,
just go to .. data labels in charts ….select format data labels … in that select the option numbers … select custom .. give the format as “#,###;-#,###” then click add .. all the zeros will be ignored in the barchart……..It Works ….
Comment from Juan Carlos
Time: Monday, November 8, 2010, 8:24 pm
Hi Jon, I have learned a lot of things from your page, since I was school, and never had a question about the procedures you do, but a few days ago, in my work (civil engineering) I did a worksheet to calculate the bearing capacity of the soil, and use the tip you gave about using check boxes for graphing, every works great, but a (I suposse) simple question arrive to me, because I have could not solve.
If I have several check boxes and I try to plot some of them, not all, always the data labels appear and I dont know how to blank them, and make apear just when they are used.
Is there a way to do it?
Don´t know how to attach the file, but i suppose this is a simple and mortal question for you, thanks a lot for your knowledge. Sorry for my English.
Comment from Jon Peltier
Time: Monday, November 8, 2010, 10:49 pm
Juan Carlos -
It’s not an easy task to hide the legend for series which are hidden in this way. What you could do, is apply a data label to the last point of each plotted series, and remove the legend. This will only show labels for plotted series, and labels make it easier to identify series than using a legend.
Comment from Colin Bowern
Time: Wednesday, August 3, 2011, 2:12 pm
This proved to be super useful on an area chart to stop the drop off to zero.
=VALUE(TEXT(formula, “0;-0;-9999999;”))
Then set the vertical axis minimum to 0.
Comment from Sam
Time: Friday, September 30, 2011, 9:07 am
Fantastic thanks ever so much for this REALLY helpful!!!
Cheets
Comment from Maria
Time: Thursday, November 24, 2011, 3:50 pm
Wow you r a geniuos, thank u , this is all new for me
Comment from Jessie
Time: Thursday, March 8, 2012, 11:16 pm
Hi, is there a way of doing this dynamically? I.e. instead of hard coding in the series name, link to the cell of the series name and only show this when non-zero? (it’s important that this series name is dynamic, as data inputs/data refreshes might not be in the same order each time). We are looking at a chart with over 50 series, and many data points. Many of these series will be zero, but will be updated and changed on a weekly basis, so the least manual input (weekly) the better. Also, is there a way of having a similar dynamic legend, which only shows the series that are non-zero. Unfortunately, I am unable to install external applications to my machine…. Thanks for your help.
Comment from Jon Peltier
Time: Friday, March 9, 2012, 12:12 am
Jessie -
I can’t think of a non-code way to do this. I guess what I’d do is whenever the chart updates, run some code to apply the new custom format, the way it’s done manually here.






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.