Sub topic 14
Tiered Rates and Thresholds with Approximate Matching
This chapter assumes you can write an exact-match XLOOKUP and an INDEX with MATCH formula, and that you understand absolute references such as $B$3. It covers lookups where the input rarely equals a key in the table, such as volume discounts, commission bands, and tax brackets.
Why exact match fails for tiers
A tier table lists the lower bound of each band and the rate that applies from that bound upward. A sales commission table might look like this on a sheet named Tiers:
| Threshold (B) | Rate (C) |
|---|---|
| 0 | 2.0% |
| 50,000 | 3.5% |
| 100,000 | 5.0% |
| 250,000 | 6.5% |
| 500,000 | 8.0% |
A deal worth 137,500 matches none of these thresholds exactly. The correct answer is the rate for the largest threshold that does not exceed 137,500, which is 100,000, so the rate is 5.0%. That is what approximate matching does. It does not guess or round to the nearest value. It finds the last threshold that is less than or equal to the input.
Approximate matching with XLOOKUP
XLOOKUP takes the match mode as its fifth argument. The value -1 means "exact match, or the next smaller item."
=XLOOKUP(B5, Tiers!$B$3:$B$7, Tiers!$C$3:$C$7, , -1)The fourth argument (if_not_found) is left empty, which is why two commas appear in a row. The formula returns the rate for the largest threshold that is less than or equal to the value in B5.
Two properties make XLOOKUP the safer choice for tier tables:
- The thresholds do not have to be sorted. With search mode
1(the default), XLOOKUP examines the whole list and picks the right row regardless of order. - If the input is smaller than every threshold, the formula returns
#N/Ainstead of a wrong rate.
The match mode 1 does the opposite: it returns the next larger item. That suits tables that store an upper bound, but it is a different table design, so make sure your mode matches the table layout.
Approximate matching with INDEX and MATCH
The older pattern uses MATCH with match type 1:
=INDEX(Tiers!$C$3:$C$7, MATCH(B5, Tiers!$B$3:$B$7, 1))MATCH returns the position of the largest value that is less than or equal to the lookup value. INDEX then returns the rate at that position. For 137,500 the thresholds give position 3, and INDEX returns the third rate, 5.0%.
The critical rule is that match type 1 requires thresholds sorted in ascending order. MATCH uses a binary search, which skips around the list instead of reading it top to bottom. On unsorted data it can return a wrong position without any error. Match type -1 finds the smallest value greater than or equal to the lookup value and requires descending order. Match type 0 is the exact match you already know.
The default match type is also 1. If you omit the third argument of MATCH, you get approximate matching on sorted data. Always type the third argument, whether it is 0 or 1, so the reader can see your intent.
How the lookup walks the table
The diagram shows how a lookup value of 137,500 resolves against the table.
The diagram reads the table linearly for clarity. MATCH type 1 reaches the same answer with a binary search, which is why sorting matters.
Applying a tier rate to an amount
Two different calculations use a tier table, and they give different results.
- Whole-amount (cliff) pricing. The single rate found by the lookup applies to the entire amount. A deal of 137,500 earns 5.0% on all 137,500, which is 6,875. The lookup formula above is all you need, multiplied by the amount.
- Marginal (bracket) pricing. Each band applies only to the slice of the amount inside it, as with income tax. The first 50,000 earns 2.0%, the next 50,000 earns 3.5%, and the remaining 37,500 earns 5.0%.
A single lookup cannot compute marginal pricing. A common approach is to add a helper column of band widths and compute each slice, then sum them:
=SUMPRODUCT((B5>Tiers!$B$3:$B$7) * (B5-Tiers!$B$3:$B$7) * Tiers!$D$3:$D$7)Here column D of the Tiers sheet holds the incremental rate for each band, meaning the band's rate minus the previous band's rate. For example D3 is 2.0%, D4 is 1.5%, and D5 is 1.5%. Each band that the amount has passed contributes the amount above its threshold, times the rate increase. Confirm which pricing rule the business uses before you build the table, because a cliff structure creates a jump where earning a little more can pay less in total.
Boundaries and edge cases
- Exact threshold values. An input of exactly 100,000 returns the 100,000 row's rate, because the comparison is "less than or equal." If the contract says "above 100,000," you need a different table or an adjusted input.
- Input below the first threshold. Include a row with threshold 0, or a very low number, so that valid inputs always land somewhere. Negative values such as returns or credits will otherwise produce
#N/A. - Text that looks like numbers. A threshold stored as text will not compare numerically. Check that the whole column is numeric.
- Percentage versus fraction. A rate of 5.0% is stored as 0.05. Keep the format consistent across the column.
- Dates as thresholds. Dates are numbers, so the same technique works for time-based tables, such as a rate that changes on specific effective dates. Look up the transaction date against the effective-date column.
Making the table safe to use
Treat the tier table as an assumption block. Give it its own sheet or a clearly labeled range, with a header row and no merged cells. If rows might be added later, size the ranges to include blank space or convert the table to an Excel table so the references expand. Then add two checks next to the table.
=IF(SUMPRODUCT(--(Tiers!$B$4:$B$7<=Tiers!$B$3:$B$6))=0, "OK", "Thresholds not ascending")This compares each threshold with the one above it and counts any that are not strictly larger. A result of zero means the list is sorted and has no duplicates. Duplicate thresholds are a real risk, since two rows with the same lower bound make the result depend on which one the lookup finds first.
For the lookup cell itself, wrap the result only when you have decided what a miss should mean. Hiding #N/A with a blanket IFERROR can disguise a missing tier as a zero commission. A clearer option is to let the error appear, or to return a visible message from the if_not_found argument of XLOOKUP.
Choosing between the two approaches
| Situation | Better choice |
|---|---|
| Thresholds may be edited or unsorted | XLOOKUP with match mode -1 |
| Workbook must open in Excel 2016 or earlier | INDEX with MATCH type 1 |
| Table stores upper bounds | XLOOKUP with match mode 1 |
| You want a loud failure on bad input | XLOOKUP, which returns #N/A below the first tier |
| Table is large and always sorted | Either, since both are fast |
Exercise
A commission table has thresholds 0, 50,000, 100,000 in B3:B5 and rates 2%, 3.5%, 5% in C3:C5. A deal of 100,000 is in B8. Write an XLOOKUP formula that returns its rate, state the result, and explain what happens if the thresholds in B3:B5 are reordered as 100,000, 0, 50,000.
Show answer
=XLOOKUP(B8, $B$3:$B$5, $C$3:$C$5, , -1) returns 5%, because 100,000 equals the third threshold and the match mode -1 accepts an exact match. If the thresholds are reordered, XLOOKUP still returns the rate stored beside 100,000, since it does not depend on sort order. The equivalent INDEX(C3:C5, MATCH(B8, B3:B5, 1)) could return a wrong rate on the reordered list, because MATCH type 1 requires ascending order.
Exercise
A tier table lists thresholds 0, 10,000, 25,000, and 25,000 with different rates in the last two rows. What problem does this cause, and which check from this chapter catches it?
Show answer
The duplicate threshold of 25,000 makes the result ambiguous for any input of 25,000 or more, since the formula returns whichever matching row it finds. The ascending-order check, which flags any threshold that is not strictly greater than the one above it, reports "Thresholds not ascending" and catches the duplicate.