Monthly Archives: September 2017
Hopefully you are familiar with applying conditional formatting to cells, and creating rules to apply more complex formatting rules. If not, check out my blog to see how you can apply conditional formats to cells.
However, when it comes to charts there is no in-built conditional formatting functionality where you can create some sort of rule and apply it to a series.
In order to create the “illusion” of conditional formatting on charts we have to create some dummy data based on our base data.
Let’s start with a simple table.
When converted into a chart it gives us this.
As you can see we have a range of products being sold and have different sales figures against each one. To make things stand out a bit more it would be nice to apply some colour coding to the bars of the chart to show which sales are good, bad or indifferent or simply to show on a colour scale how sales are performing.
For this example, let’s say I just want to show a RAG (Red/Amber/Green) system for each product.
First, decide what your break points are going to be i.e. what determines if something should be red, amber or green;
Amber <= 3500
Green > 3500
Once we have our break points we can set up our table to create the dummy data.
Add a couple of new lines above your table and if you want, label them something like Lower and Upper to represent the lower and upper bounds of your range of values e.g. 0 to 1500 for red.
It’s worth also adding some labels so that these appear in your legend when you create the chart so people understand the meaning of the colours. In this example, I used the formula = C2&” – “&C3 to build up the label for the red values.
Now we build up some IF statements to determine which category the actual value from the base data falls into i.e. Product A should be in the amber section. We will start by creating a nested IF statement in cell C5 (in this example) that will test if the sales value for Product A is between 0 and 1500. If it is, then display the number, otherwise show #NA. We need to have #NA as this prevents anything from being plotted in the chart. By fixing certain elements of the formula (see my blog on absolute vs. relative referencing if you are unsure about what I have done) so that the formula can be copied across the columns and then down the rows ensuring it works in all cases.
Once applied to all the cells in the modified table, each sales value for each product should only appear once in the new columns.
Now it’s time to replot the chart but this time using the dummy data.
Highlight all the data apart from the original values.
Use a stacked column chart to display your data and then apply whatever formatting you want to get your end chart.
Because of the way the data has been set up, if any of the values change, the formatting you have applied will automatically change based on the values.