Sub topic 3
Highlighting top and bottom values
Top/Bottom Rules highlight the largest or smallest values in a range without you sorting the data or writing a formula. This chapter assumes you can select ranges, apply a fill color, and write a simple formula such as =A1+B1. It also assumes you have seen the Highlight Cells Rules from the previous chapter.
Where the rules live
Select the cells you want to evaluate, then open Home > Conditional Formatting > Top/Bottom Rules. The menu offers six rules:
| Rule | What it highlights |
|---|---|
| Top 10 Items | The N largest values (default N = 10) |
| Top 10 % | The largest values making up N percent of the cell count |
| Bottom 10 Items | The N smallest values |
| Bottom 10 % | The smallest values making up N percent of the cell count |
| Above Average | Values greater than the mean of the range |
| Below Average | Values less than the mean of the range |
Despite the labels, you can change the "10" to any whole number from 1 to 1000 for item rules, or from 1 to 100 for percent rules. Each rule opens a dialog with a number box and a format drop-down. The drop-down offers presets such as Light Red Fill with Dark Red Text, or you can choose Custom Format to set your own font, border and fill.
Top and bottom N items
Suppose B2:B21 holds monthly sales for 20 sales representatives. To mark the three best results:
- Select
B2:B21. - Choose Conditional Formatting > Top/Bottom Rules > Top 10 Items.
- Change
10to3. - Pick a format and select OK.
The rule is dynamic. If you change a value so that a different cell enters the top three, the highlight moves immediately. Nothing is stored about which cells "were" the top three.
Bottom 10 Items works the same way, using the smallest values. A common pattern is to apply both rules to the same range with different colors: green for the top three and red for the bottom three.
Ties
The rule compares values against a cutoff. If the third-largest value is 5000 and two cells hold 5000, both are highlighted, so you may see more than N highlighted cells. Excel does not break ties arbitrarily. If you need exactly N highlighted cells, you must break ties yourself, for example by adding a tiny helper value or by using a formula rule.
What counts as a value
Top/Bottom rules consider only numeric cells (including dates, which are numbers). Text and blank cells are ignored. Cells containing errors such as #N/A are also skipped, so a single error does not stop the rule from working. Numbers stored as text are treated as text and are ignored, which is a frequent cause of "the rule skipped my biggest value." Check for the small green triangle in the cell corner, or test with =ISNUMBER(B2).
Top and bottom percent
The percent rules use the number of cells, not the sum of the values. In a range of 20 numeric cells, Top 10 % highlights the top 10 percent of the cells, which is 2 cells. Excel rounds the count down, but it always highlights at least one cell.
This is a different question from "which values make up 10 percent of total sales." If you need that, you need a cumulative calculation in a helper column.
| Numeric cells in range | Top 10 % highlights |
|---|---|
| 5 | 1 cell (minimum of one) |
| 20 | 2 cells |
| 45 | 4 cells |
| 100 | 10 cells |
Ties apply here too, so the highlighted count can exceed the figures in the table.
Above and below average
Above Average and Below Average calculate the mean of the selected range and compare each cell with it. The dialog also lets you choose related comparisons through the drop-down: above, below, equal to or above, equal to or below, and one, two or three standard deviations above or below the average.
These standard deviation options help you flag outliers. "2 Std Dev Above" marks values more than two standard deviations over the mean. In roughly normally distributed data, only a few percent of values qualify.
Note that the average is calculated from the cells in the rule's range. If a rule is applied to B2:B21, the average covers only those cells. Rows hidden by a filter are still included in the calculation. That matters if you filter the data and expect the average to reflect only visible rows. It will not.
Equivalent formula rules
Top/Bottom rules are convenient but limited. Because they always evaluate the cells in the applied range as one group, they cannot do two common tasks: finding the top N within each category, or highlighting a whole row based on a value in one column. Both need a formula rule, which a later chapter covers in detail. The patterns below show how the built-in rules map to formulas, so you can see what Excel is doing.
To mimic Top 3 Items on B2:B21, create a formula rule with the active cell at B2 and this formula:
=B2>=LARGE($B$2:$B$21,3)LARGE(range, 3) returns the third-largest value. Any cell at or above it is highlighted. This reproduces the tie behavior described earlier. The range is absolute because it must not move as the rule is evaluated for each cell. The B2 reference is relative because it must follow the cell being tested.
To highlight the entire row of each top performer, apply the rule to $A$2:$E$21 and lock the column:
=$B2>=LARGE($B$2:$B$21,3)The only change is $B2 in place of B2. The column is locked, so every cell in the row looks at column B, while the row number remains relative.
For the bottom values, swap in SMALL and reverse the comparison:
=$B2<=SMALL($B$2:$B$21,3)Edge cases and common mistakes
- Selecting extra cells. If you include a header row or a total row in the selected range, the total will probably be the top value and the rule will highlight only it. Select just the data cells.
- Selecting several columns at once. A rule applied to
B2:D21ranks all 60 values together, not each column separately. To rank each column on its own, apply one rule per column. - Percent rule on small ranges. With few cells, the one-cell minimum can make Top 10 % look like Top 1 Item.
- Expecting the rule to see new rows. A rule covers only its Applies to range. If you add rows below
B21, they are not ranked until you extend the range in the Rules Manager. Converting the data to an Excel Table usually extends the range automatically. - Text-formatted numbers. As noted, these are skipped silently.
- Mixed signs. Bottom rules pick the most negative numbers first. A value of -50 is "lower" than 2, which may not be what you mean if you are looking for values closest to zero.
How the rule evaluates a range
The following diagram shows the decision path Excel follows for a Top 10 Items rule.
Choosing between built-in and formula rules
Use the built-in rule when you want a quick highlight of one column and the default tie behavior is acceptable. Use a formula rule when you need whole rows, a top N per group, an exact count, or a cutoff that comes from another cell. For example, replacing the 3 in LARGE with $H$1 lets users change N by typing into one cell, which the built-in dialog cannot do from a cell reference.
Exercise
A range C2:C31 contains 30 numeric sales figures. You apply Top 10 % and Excel highlights 4 cells. Give two possible reasons it is not 3 cells, and write a formula rule that highlights the top 3 values only (assuming no ties) for the same range with the active cell at C2.
Show answer
Two possible reasons: (1) ties at the cutoff value cause extra cells to be highlighted; (2) the range may contain more numeric cells than expected, for example 40 if the Applies to range is larger than C2:C31, since the percent is based on the number of numeric cells in the applied range. Ten percent of 30 cells is 3, so a fourth highlight points to a tie or a larger range. The formula rule is =C2>=LARGE($C$2:$C$31,3). The reference C2 is relative and the range is absolute.
Exercise
Your data is in A2:E21 and column B holds scores. Write the formula rule, and the Applies to range, that shades the entire row of the two lowest scores.
Show answer
Applies to =$A$2:$E$21, with the active cell at A2, and the formula =$B2<=SMALL($B$2:$B$21,2). Locking column B with $B makes every cell in the row test the score, while the relative row number moves down the range.