Pages

Thursday, 18 July 2013

Colors in Chart Labels


This post is part of our spreadcheats series – 30 Excel and Charting Tips & Hacks aimed to make day to day spreadsheeting fun and productive.
One of the most common charts is “YoY Growth Rates of Our Superawesomekickass Product”. While not everyone may have a superawesomekickass product, most of us in fact make a YoY (Year on Year) growth rate charts for various types of data.
A simple label formatting hack can improve the effectiveness of these charts by adding color to differentiate positive vs. negative growth (or mediocre vs. sky rocketing growth rates). See this example:
Excel Chart - Colors in Data Labels - How to
You can get this effect by applying custom number formatting to the data label. It is one of my favorite tricks in excel and I have written about it in introduction to custom cell formatting in excel, number formatting in excel using custom codes, showing decimal values only when needed articles.

How you can get colors in Axis Labels

First apply data labels to your chart and now select the data labels and press ctrl+1 (aww, come on now, you are reading this blog, you should what ctrl+1 means) and go to numbers tab. Select “custom” as category and specify the formatting code like this:
custom format code for getting colors in chart labels
[blue]+0%;[red]-0%
Now, that was easy, isn’t it. But you might think, “Chandoo, what the heck the above format code is doing?”
Well, it tells excel to apply red color and add a minus symbol if the data label value is less than zero and apply blue color and add + symbol if the value is above zero. You see the custom number formatting codes have 3 parts in them, like this:
formatting for positive numbers ; formatting for negative numbers ; formatting for zero values
If you are noob (hi noob!) and lost in all these codes and square brackets, you may want to checkout our post on introduction to number formatting in excel to learn more about custom codes.

Ok, that was fun, What else you can do?

You can do much more using custom codes to format data labels. For example, a code like [Red][<0.15]0%;[Blue][>=0.15]0%; will, Oh, forget it, you can guess that. Just remember that excel allows only 3 parts in custom codes. So go nuts, but just thrice.

No comments: