Find a band or tax bracket with an approximate match
Bands, the last match and positions8 minPremium
Builds on Look up a price with XLOOKUP.
An online store in Oregon gives bigger discounts on bigger orders, and the rates change twice a year. So the rates sit in a small table of thresholds that anyone can update, and one lookup reads the right row for each order.
How it works
With TRUE as its last argument, VLOOKUP reads the table's first column as the points where bands begin, sorted from smallest to largest, and returns from the last row whose start is less than or equal to your value. Picture climbing a staircase and stopping on the highest step you can reach without going past your amount.
That puts two rules on the first column. It holds where each band starts, beginning with the lowest possible value, often 0, because anything below the first start shows #N/. And it runs from smallest to largest, or VLOOKUP can stop on the wrong row, often without an error.
XLOOKUP does the same with a match_mode of -1, exact match or next smaller item, and it doesn't need the list sorted. When a table gives where each band ends instead, as in "up to 5 kg", use 1, exact match or next larger item.
A table of thresholds beats a nested IF for bands: the limits sit in cells where anyone can check them, and a new band is a new row.
Example
An invoice's late fee depends on how many days it's overdue: nothing up to 14 days, $25 from 15 days, $50 from 30 and $100 from 60. The starting days are in A2:A5, the fees in B2:B5, and the days overdue in E2.
=VLOOKUP(E2,A2:B5,2,TRUE)- Step 1: VLOOKUP takes the days overdue in
E2, 37. - Step 2: Down
A2:A5, 0, 15 and 30 are at most 37 and 60 is more, so it stops on the 30 row. - Step 3: E3 shows the fee from that row, $50.
Common mistakes
=VLOOKUP(asks for an exact match, so 37 days showsE2, A2:B5, 2, FALSE) #N/: the only days in the table are 0, 15, 30 and 60.A - A first column out of order can send VLOOKUP to the wrong band, often with no error to warn you. Sort it smallest to largest, or use XLOOKUP with -1.
- A table of upper limits (up to 14 days, up to 29) used with TRUE puts every value that falls between two limits in the band below. Use XLOOKUP with 1.
In short
- An approximate match finds the band: the last start at or below the value.
=VLOOKUP(needs the first column sorted from smallest to largest, from the lowest possible value.value, table, column, TRUE) - XLOOKUP with -1 finds the next smaller start in any order, and with 1 the next larger limit.
- Write TRUE even though it's the default, so the next reader knows the approximate match is on purpose.
Practice
Premium4 formulas.
Practice is part of Premium
Every lesson is free to read, and you can practice the free lessons without an account. This lesson's exercises are part of Premium, which you add to a free account.
Have one? Sign in