Peltier Technical Services, Inc.
 

Excel Charting Utilities | Custom Solutions | Training | Charts and Tutorials | PTS Blog


Peltier Tech
Chart Utilities

PTS Waterfall Chart Utility
PTS Cluster-Stack Column Chart Utility
PTS Box and Whisker Chart Utility
PTS Marimekko Chart Utility
PTS Dot Plot Utility
PTS Cascade Chart Utility

 

Excel Dashboards

 

Books at Amazon.com

 

Buy me a coffee

If this topic or the whole site has been helpful, please support further development by treating me to a cup of coffee.

 

Simple Conditional Chart Example.

It's relatively easy to apply conditional formatting in an Excel worksheet. It's a built-in feature on the Format menu, and there many resources on the web to get help (see for example what Debra Dalgleish and Chip Pearson have to say). Charts are a different story.

Many people ask how to make a conditional chart, that is, how to change the formatting of a chart's plotted points (markers, bar fill color, etc.) based on the values of the points. This can be done using VBA to change the individual chart elements, but if there are more than a few points, VBA is noticeably slow about making the changes. Also, Excel is designed to plot points and series very quickly from the worksheet. So the following technique works very well without resorting to macros, with the added advantage that you don't have to muck about in VBA.

I took the following sample data and charts, and used this technique to apply different formats to each group of 3 (0-3, 3-6, etc.).

  A B
1    
2    
3 X Values Y Values
4 1 6
5 2 2
6 3 2
7 4 8
8 5 12
9 6 8
10 7 8
11 8 3
12 9 9
13 10 2
14 11 5
Preconditioned XY Chart
Preconditioned Column Chart

I fixed up the spreadsheet range as shown below. In B1:B2, I added labels "min" and "max", and in C1:F2 I entered numbers to serve as limits on the different colored points. In C3:F3 I put my headers "Between X and Y"; I put this formula into C3, then dragged it across to include F3:

="Between "&C1&" and "&C2

Finally, I selected C4:F14, entered this formula into C4:

=IF($B4>C$1,IF($B4<=C$2,$B4,NA()),NA())

and pressed Ctrl-Enter so all cells within the selected range will contain the formula. Notice the careful placement of dollar signs to assure that certain absolute rows and columns were maintained in these formulas.

  A B C D E F
1   min 0 3 6 9
2   max 3 6 9 12
3 X Values Y Values Between 0 and 3 Between 3 and 6 Between 6 and 9 Between 9 and 12
4 1 6 =IF($B4>C$1,IF($B4<=C$2,$B4,NA()),NA())  
5 2 2        
6 3 2        
7 4 8        
8 5 12        
9 6 8        
10 7 8        
11 8 3        
12 9 9        
13 10 2        
14 11 5        

Finally the table looks like this. Each column contains either the value from column B if the value fits within min and max, or the #N/A error if it doesn't fit. If you use zero or any string (even ""), Excel will plot a zero. Using NA() assures that Excel will skip that point without plotting it.

  A B C D E F
1   min 0 3 6 9
2   max 3 6 9 12
3 X Values Y Values Between 0 and 3 Between 3 and 6 Between 6 and 9 Between 9 and 12
4 1 6 #N/A 6 #N/A #N/A
5 2 2 2 #N/A #N/A #N/A
6 3 2 2 #N/A #N/A #N/A
7 4 8 #N/A #N/A 8 #N/A
8 5 12 #N/A #N/A #N/A 12
9 6 8 #N/A #N/A 8 #N/A
10 7 8 #N/A #N/A 8 #N/A
11 8 3 3 #N/A #N/A #N/A
12 9 9 #N/A #N/A 9 #N/A
13 10 2 2 #N/A #N/A #N/A
14 11 5 #N/A 5 #N/A #N/A

Now simply add the new series to the chart and format the the way you want them to appear. The easiest way is to select the range (C3:F14 to include the headers as legend entries), copy, then select the chart, paste special, by columns, series names in first row.

For a Line or XY Scatter chart, I kept the original series, leaving the connecting lines but removing the original markers. The other series have various colors and shapes.

Preconditioned XY Chart

For a Radar (Spider) chart, I followed the same protocol as with the Line/XY chart.

Preconditioned Radar Chart

For a Column (or Bar) chart, I removed the original data, then made sure the chart was a Stacked Column type, not a Clustered Column type. Select the chart, and from the Chart menu, select Chart type, and pick the second column chart option, not the first. Then I filled the columns with different colors.

Preconditioned Column Chart

To download a zipped Excel file with this example, click on this link.

Other examples of this technique include:


Simple Conditional Charts 2


Special Format for Minimum and Maximum


Use an Arrow to Indicate Special Points

 

 

Page copy protected against web site content infringement by Copyscape

 

PTS Waterfall Chart Utility PTS Cluster-Stack Column Chart Utility PTS Box and Whisker Chart Utility PTS Marimekko Chart Utility PTS Dot Plot Utility PTS Cascade Chart Utility

 

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


Peltier Technical Services, Inc.

Commercial Utilities | Custom Solutions | Training | Charts and Tutorials | PTS Blog

Peltier Technical Services, Inc., Copyright © 2010. All rights reserved.
You may link to this article or portions of it on your site, but copying is prohibited without permission of Peltier Technical Services.

Microsoft Most Valuable Professional

Microsoft Most Valuable Professional

My MVP Profile