Peltier Tech Blog

Excel Chart Add-Ins | Training | Custom Solutions | Charts and Tutorials | PTS Blog

 

Main menu:

 
Peltier Tech
Chart Add-Ins

Peltier Tech Waterfall Chart Utility
Peltier Tech Cluster-Stack Chart Utility
Peltier Tech Box and Whisker Chart Utility
Peltier Tech Marimekko Chart Utility
Peltier Tech Dot Plot Utility
Peltier Tech Cascade Chart Utility

 
Excel Dashboards

Subscribe

Site search

Subscribe

Site search


Recent Posts

Recently Commented

Popular Posts

Archive


 

Categories


 

Privacy Policy

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

Hide Series Data Label if Value is Zero

by Jon Peltier
Tuesday, May 12th, 2009
Peltier Technical Services, Inc., Copyright © 2010.
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.

stacked columns with series name labels on points with zero values

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.

stacked columns with Y value labels on points with zero values

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.

stacked columns with fake name labels only on points with positive values


Related Posts:

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

Learn how to create Excel dashboards.

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 ….

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.





Subscribe without commenting

Peltier Tech Waterfall Chart Utility Peltier Tech Cluster-Stack Chart Utility Peltier Tech Box and Whisker Chart Utility Peltier Tech Marimekko Chart Utility Peltier Tech Dot Plot Utility Peltier Tech Cascade Chart Utility

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