> AI agents: this is one page from Mammoth Analytics documentation. The index of all pages as Markdown is https://mammoth.io/docs/llms.txt. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get Markdown.

# Which highlight rule wins when several rules match

> How Mammoth Conditional Highlights decide which colour a cell gets when several rules or a Color Scale match, with a worked sales-target example.
>
> Applies to: Where: View › Conditional Highlights panel

Rules in the **Conditional Highlights** panel are checked from the top down, and the top rule has the highest priority. Drag rule cards to change the order. To create rules, see [Highlight cells and rows with colour](https://mammoth.io/docs/learn/clean-and-shape/highlight-values/).

## How Mammoth picks the colour for each cell

1. For each cell, rules are checked from top to bottom.
2. The first rule that matches the row and applies to that cell colours it. No further rules are checked for that cell.
3. If no rule matches, the cell has no highlight.

A rule in **Cells** mode colours only its chosen columns, so lower rules can still colour other cells in the same row.

```plaintext
Rules (top to bottom):
  1. Sales > 10,000  →  Red background
  2. Sales > 5,000   →  Yellow background
  3. Region = "West" →  Blue background
```

| Row | Result |
| --- | --- |
| Sales = 12,000, Region = "West" | Rule 1 matches: red. Rules 2 and 3 are skipped. |
| Sales = 7,500, Region = "North" | Rule 1 doesn't match. Rule 2 matches: yellow. Rule 3 is skipped. |
| Sales = 2,000, Region = "West" | Rules 1 and 2 don't match. Rule 3 matches: blue. |

Put your most specific or most important rules at the top.

Color Scales take part in the same order. A Color Scale above a Condition Rule colours every value in its column, so lower Condition Rules can't colour cells there. To let Condition Rules win, put them above the Color Scale.

## Example: colour sales reps against a target

The `Monthly Sales` target is $10,000. You want to see at a glance who hit it, who is close and who missed.

| Rule | Condition | Colour | Position |
| --- | --- | --- | --- |
| 1 | Monthly Sales &gt;= 10,000 | Green background | Top |
| 2 | Monthly Sales &gt;= 9,000 | Yellow background | Second |
| 3 | Monthly Sales &lt; 9,000 | Red background | Third |

Reps at or above target turn green. Reps from $9,000 to $9,999, within 10% of target, turn yellow. Everyone else turns red. A rep at $15,000 matches rule 1 first, so rules 2 and 3 are never checked. For a new target, edit rules 1 and 2. Rule 3 catches everything the first two miss.

Rows with an empty `Monthly Sales` match none of these rules, because an empty cell doesn't equal a number. Add a fourth rule with **is Empty** to flag missing data.

## Related

- [Highlight cells and rows with colour](https://mammoth.io/docs/learn/clean-and-shape/highlight-values/): create, edit and reorder rules.
- [See and filter rows that match a highlight](https://mammoth.io/docs/learn/clean-and-shape/highlight-focus-mode/): check which rows a rule affects.
- [Filter rows](https://mammoth.io/docs/learn/clean-and-shape/filter-rows/): the condition builder and its operators.

---
Source: https://mammoth.io/docs/learn/clean-and-shape/highlight-rule-order.md · Updated: 2026-11-08
