Sub topic 5
Showing distribution with color scales
A color scale fills each cell in a range with a color that depends on where its value falls between the lowest and highest values. This chapter assumes you can select ranges, apply a fill color, and open the Conditional Formatting menu on the Home tab. It also assumes you have read the earlier chapters on highlight rules and data bars. Here you will learn how to apply two-color and three-color scales, set the thresholds that control them, and avoid the errors that make a scale misleading.
What a color scale shows
Highlight rules answer a yes-or-no question: does this cell meet the condition? A color scale answers a different question: where does this value sit compared with the others? Each cell gets a color on a gradient, so you can see clusters, outliers and trends across a grid of numbers without reading each one.
Color scales suit grids where the numbers are comparable, such as monthly sales by region, test scores by class, or temperatures by day. Data bars show the size of each value as a bar. A color scale shows relative position as color, and it works well on a dense table where bars would not fit.
Applying a built-in scale
- Select the numeric range, for example
B2:M13. - On the Home tab, choose Conditional Formatting, then Color Scales.
- Point at a swatch to preview it, then click to apply it.
The gallery has two kinds of swatch:
| Kind | Colors used | Typical meaning |
|---|---|---|
| Two-color scale | Minimum color to maximum color | Low to high, one direction |
| Three-color scale | Minimum, midpoint and maximum colors | Low, middle and high, with a neutral center |
The swatch name tells you the order. "Green - Yellow - Red Color Scale" puts green on the highest values and red on the lowest. "Red - Yellow - Green Color Scale" does the opposite. Check the order before you apply it, because a scale that colors high costs green and high sales red will mislead readers.
How Excel assigns the colors
For each cell, Excel compares the value with three thresholds: the minimum, the midpoint (three-color scales only) and the maximum. Values at a threshold get that threshold's color. Values between two thresholds get a blend in proportion to their position.
By default the thresholds are:
- Minimum: the lowest value in the range.
- Midpoint: the 50th percentile, which is the median.
- Maximum: the highest value in the range.
Because the midpoint is a percentile and not the average, the middle color marks the median value. In a skewed set of numbers, half the cells fall on each side of the neutral color even when most of them sit close together in value.
Customizing the scale
To change the thresholds or colors, open Conditional Formatting, then Manage Rules. Select the color scale rule and choose Edit Rule. The Edit Formatting Rule dialog has a row for each threshold with three settings: Type, Value and Color.
Threshold types
| Type | What the Value box means | Example use |
|---|---|---|
| Lowest Value / Highest Value | Not used. Excel finds the extreme itself. | Default behavior |
| Number | A fixed number | Scores where 0 and 100 are the true limits |
| Percent | A percentage of the way between the lowest and highest values | Fixed proportions of the observed range |
| Percentile | A rank position within the data, from 0 to 100 | Reducing the effect of outliers |
| Formula | A formula or cell reference that returns a number | Thresholds that live in input cells |
Percent and Percentile are easy to confuse. Percent works on the range of values. In data running from 0 to 200, the 50 percent point is 100. Percentile works on rank. The 50th percentile is the median, which could be 40 if most values are small.
Handling outliers
One extreme value can flatten a default scale. Suppose a column holds the values 12, 15, 14, 16, 13 and 900. The maximum is 900, so every normal value lands near the minimum color and looks the same. Two fixes work:
- Set the maximum to the 90th or 95th percentile. Values above it all take the maximum color, and the normal values spread across the gradient.
- Set the maximum to a Number you consider the top of the normal range.
Anchoring a scale to a meaningful midpoint
A three-color scale is most useful when the middle color means something, such as zero for profit or a target for sales. Set the midpoint Type to Number with Value 0, and use red for the minimum, white for the midpoint and green for the maximum. Negative values then shade toward red, positive values shade toward green, and zero is white.
You can also point a threshold at a cell. Choose Formula as the Type and enter an absolute reference such as =$H$1. Changing the target in H1 then updates the colors without editing the rule.
=$H$1Use an absolute reference here. A relative reference in a threshold is interpreted relative to the active cell and can shift in unexpected ways.
A worked example
You have monthly sales for five regions in B2:G6, with months in the header row. You want to see which region and month combinations are strong or weak.
- Select
B2:G6. Do not include the header row or a totals column, because totals are much larger than monthly values and would distort the scale. - Choose Conditional Formatting, then Color Scales, then the Red - Yellow - Green scale, so low sales are red and high sales are green.
- Open Manage Rules, select the rule, and choose Edit Rule.
- Set the minimum Type to Percentile with Value
5, and the maximum Type to Percentile with Value95. One unusually good or bad month will no longer wash out the rest. - Click OK twice.
The grid now shows the pattern at a glance. A column of green points to a strong month across regions, and a row of red points to a weak region.
Scale scope and separate ranges
A color scale compares cells only within the range it covers. This has two consequences.
- If you apply one scale to
B2:G6, all 30 cells share a single gradient. A region with small values will look uniformly red next to a large region. - If you want each region compared with its own months, apply a separate scale to each row:
B2:G2, thenB3:G3, and so on. You can apply them one at a time, or use Manage Rules to confirm that each rule has the correct Applies to range.
Choose the scope to match the question. A shared scale asks which cells are high or low overall. Row-by-row scales ask which months were strong or weak for each region.
Common problems
- Text and blanks. Text cells are ignored by the scale and keep their normal fill. Blank cells are also ignored. A zero is a real number and gets a color, which can pull the minimum down. If zeros mean "no data," replace them with blanks or set the minimum to a Number.
- Errors in the range. A cell containing an error such as
#N/Aor#DIV/0!prevents the scale from being drawn on some versions of Excel. Wrap the source formulas inIFERROR, or exclude the errors from the range. - Manual fills. A color scale overrides a manual fill color in the same cell. If a cell shows a color you did not expect, check the Rules Manager before checking the fill.
- Hidden values. Hidden rows and filtered rows still count when Excel finds the lowest and highest values. A filter does not recalculate the scale for the visible rows.
- Color vision. A red-to-green scale is hard to read for people with red-green color blindness. Prefer a scale such as blue to white to orange, or add values and borders so the colors are not the only cue.
- Printing. Printing in grayscale turns colors into similar shades of gray. Check a print preview if the sheet will be printed.
Combining scales with other rules
You can apply a color scale and other rules to the same cells. A color scale controls the fill, so a highlight rule that also sets a fill color will conflict with it, and the rule higher in the list in the Rules Manager wins. Combine them by giving each a different job. Let the color scale control the fill, and let a formula rule control the font, for example bold text for values below a threshold. A rule that sets only the font does not conflict with the scale.
Choosing a scale
| Situation | Suggested scale |
|---|---|
| Values run from low to high with no meaningful center | Two-color, such as white to blue |
| Values have a natural center, such as zero or a target | Three-color with the midpoint set to that Number |
| Data has a few extreme outliers | Either type, with percentile thresholds at 5 and 95 |
| Compare each row or column on its own | A separate scale per row or column |
| Readers may have color blindness | Blue and orange, or a single-hue scale |
Exercise
A column of profit values contains positive and negative numbers. You apply the default Green - Yellow - Red scale. The cells near zero look yellow only by chance, and one large loss makes most other cells look the same. How would you change the rule so zero is neutral and the large loss does not flatten the scale?
Show answer
Edit the rule in Manage Rules. Change the midpoint Type to Number with Value 0 and set its color to white, so zero is the neutral color. Set the minimum Type to Percentile with Value 5, so the large loss takes the minimum color without stretching the gradient. Optionally set the maximum to the 95th percentile for the same reason. Choose red for the minimum and green for the maximum, so losses shade red and profits shade green.
Exercise
You apply one color scale to a table of monthly sales for a small store and a large store. The small store's row is almost entirely red. What caused this, and how do you fix it?
Show answer
One scale covers the whole range, so the colors are assigned by comparing every cell with the same lowest and highest values. The small store's values are low compared with the large store's, so they fall near the minimum color. To compare each store with its own months, apply a separate scale to each store's row, such as B2:G2 and B3:G3, and remove the single scale that covers the whole table.