Sub topic 3
Highlighting top and bottom values
This chapter assumes you can select ranges, apply a fill and font color, and have used a basic Highlight Cells rule. It covers the Top/Bottom Rules menu. You will use it to flag the largest or smallest values in a range, or values above or below the average.
What the Top/Bottom rules do
Top/Bottom Rules format cells by their rank within the selected range. You don't type a fixed threshold such as 1000. Excel works out the cutoff each time the data changes, so the highlighting follows the numbers.
Find them under Home > Conditional Formatting > Top/Bottom Rules. There are six choices:
| Rule | What it highlights |
|---|---|
| Top 10 Items | The N largest values (N defaults to 10) |
| Top 10 % | The largest N percent of the cells |
| Bottom 10 Items | The N smallest values |
| Bottom 10 % | The smallest N percent of the cells |
| Above Average | Values greater than the range average |
| Below Average | Values less than the range average |
The names say "10", but you can change the number to any value from 1 to 1000 for item rules, or 1 to 100 for percent rules.
Worked example: top 3 sales
Suppose B2:B21 holds monthly sales figures for 20 reps. To highlight the three best results:
- Select B2:B21.
- Choose Home > Conditional Formatting > Top/Bottom Rules > Top 10 Items.
- Change 10 to 3.
- Pick a format from the drop-down, such as Green Fill with Dark Green Text, then select OK.
The three largest cells are now shaded. If a rep's figure is corrected from 4,200 to 9,800, the shading moves without any further action.
To flag the weakest results as well, repeat the steps with Bottom 10 Items and a different format, such as Light Red Fill. Both rules can live on the same range.
Percent rules and average rules
Top 10 % works on the count of cells in the range. In a range of 20 numbers, 10 percent highlights 2 cells. Excel rounds down, so a range of 25 numbers at 10 percent highlights 2 cells, not 3.
Above Average and Below Average compare each cell to the mean of the whole selected range. If your range contains one very large outlier, the average rises and fewer cells count as above it. In that case consider whether the median would suit you better. The built-in rule can't use the median, but a formula rule can:
=B2>MEDIAN($B$2:$B$21)Apply this with B2:B21 selected and B2 as the active cell. The range is locked with $, and the cell being tested is relative. The next chapters cover this in detail.
Customizing the format
The drop-down in each dialog offers presets. Choose Custom Format to set any font style, border, or fill. Keep the format simple, because a rule that changes a cell's font size or shape can make a table hard to read.
Common errors
- Ties produce more cells than N. If the third and fourth largest values are equal, both are highlighted, so a "Top 3" rule can shade four cells.
- Selecting the wrong range. The rank is calculated only within the cells you selected. If you select a single column but your data is a table of several columns, the rule compares values within that column only. Select the whole block if you want one ranking across all columns.
- Including the header or total row. A total row is usually the largest number, so it takes the top spot. Exclude totals from the selection.
- Expecting row highlighting. These built-in rules format only the ranked cell. To shade an entire row based on a rank, you need a formula rule, for example
=$B2>=LARGE($B$2:$B$21,3)applied to A2:E21.
Editing or removing a rule
To change N or the format later, select a cell in the range and open Home > Conditional Formatting > Manage Rules. Select the rule, choose Edit Rule, and adjust the number or format. Later chapters cover the Rules Manager fully.
Exercise
A range of 40 numbers has a Top 10 % rule applied. How many cells are highlighted, assuming no ties? Then name one reason a Top 5 Items rule might highlight six cells.
Show answer
Ten percent of 40 is 4, so four cells are highlighted. A Top 5 Items rule can highlight six cells when values tie at the cutoff, for example when the fifth and sixth largest values are equal, because Excel highlights every cell that matches the cutoff value.
Exercise
Write a formula rule that shades the whole row A2:E21 when the value in column B is among the 3 smallest in B2:B21. Which cell is active when you create it?
Show answer
Use =$B2<=SMALL($B$2:$B$21,3). Select A2:E21 with A2 as the active cell. The column is locked with $B, the range is fixed with absolute references, and the row is relative so each row tests its own value.