XLOOKUP Approximate Match Returns the Wrong Tier
XLOOKUP match_mode 2 is wildcards, not VLOOKUP's approximate match. For a mid-tier amount, match_mode -1 returns the next rate down.
On this page
A shipping or commission table should return the rate for the next breakpoint down. For a spend of 250 on this list, exact-match XLOOKUP comes back none, and match_mode 2 does the same. The next rate down is 8%, and that is match_mode -1, not 2. Mode 2 is wildcards, not VLOOKUP’s approximate match.
This page is a wrong bracket, not a missing-key cleanup and not a * / ? tutorial. For #N/A when the value is visible in the list, see XLOOKUP Returns #N/A Even Though the Value Exists: 7 Fixes. For wildcard patterns, see XLOOKUP Wildcard and Partial Match. These results were measured in Google Sheets. I did not re-run the match_mode cases in Excel.
Four match modes on the same mid-tier amount
Enter this rate table in A1:B5. Type the breakpoints as numbers. Store the rates as 0.05, 0.08, 0.12, and 0.15 (percent format is fine; the stored values are still those fractions).
| Spend from | Rate |
|---|---|
| 0 | 5% |
| 100 | 8% |
| 500 | 12% |
| 2000 | 15% |
Put 250 in D2. That amount is past the 100 row and short of the 500 row, so the next rate down is 8%.
=XLOOKUP(D2,A2:A5,B2:B5,"none",0)
=XLOOKUP(D2,A2:A5,B2:B5,"none",2)
=XLOOKUP(D2,A2:A5,B2:B5,"none",-1)
=XLOOKUP(D2,A2:A5,B2:B5,"none",1)
The fifth argument is match_mode. The fourth argument is the value to return when nothing qualifies; I used the text none so a miss is visible. If you omit it, a miss is #N/A.
| match_mode | Meaning | Result for 250 |
|---|---|---|
0 (also the default) | Exact match only | none, because 250 is not a breakpoint |
2 | Wildcard match | none. 250 has no * / ?, and this is not a tier lookup |
-1 | Exact, or the next smaller item | 8% (the 100 row) |
1 | Exact, or the next larger item | 12% (the 500 row) |
If you need the next rate down, the mode is -1, not 2 and not the omitted default.
Exact, below the first, and above the last
The same four formulas, with only D2 changed:
| D2 | What it is | 0 | 2 | -1 | 1 |
|---|---|---|---|---|---|
| 100 | exact breakpoint | 8% | 8% | 8% | 8% |
| 250 | between 100 and 500 | none | none | 8% | 12% |
| -10 | below the first breakpoint | none | none | none | 5% |
| 5000 | above the last breakpoint | none | none | 15% | none |
The -10 and 5000 rows are the ones that surprise people who thought “approximate” always returns something. Mode -1 has nothing smaller than 0, and mode 1 has nothing larger than 2000.
The list does not have to be sorted for -1 and 1
On a copy of the table sorted descending (2000, 500, 100, 0), the four match_mode results for 250, 100, -10, and 5000 were the same as on the ascending list: -1 still returned 8% for 250, and 1 still returned 12%.
On a third copy, the rows were out of order: 0, 500, 100, 2000. For 250, -1 was still 8% and 1 was still 12%.
VLOOKUP(D2,A2:B5,2,TRUE) is a useful contrast only. For 250 it returned 8% on the ascending table, the same next-smaller rate as XLOOKUP -1. On the descending table it returned 5%, the first row’s rate, not 8%. On the out-of-order table it happened to return 8%. Approximate VLOOKUP is the subject of VLOOKUP Returning the Wrong Value? Fix Approximate Match First.
VLOOKUP(D2,A2:B5,2,FALSE) for 250 on the ascending table was #N/A: “Did not find value ‘250’ in VLOOKUP evaluation.” VLOOKUP has no next-larger mode and no if_not_found argument. That comparison sits in XLOOKUP vs INDEX MATCH vs VLOOKUP.
Binary search is a separate argument
search_mode 2 and -2 are binary search, and they are the sixth argument, not a substitute for match_mode. For 250 with match_mode -1 on the ascending table, search_mode 2 still returned 8%, but search_mode -2 returned none. On the out-of-order table, both binary modes returned 8% for the same lookup. I would not rely on binary search here; the default search plus match_mode -1 is the form that stayed with the next-smaller rate on every layout I ran.
One wildcard row, then stop
Mode 2 is for patterns, not tiers. With D2 set to the text 100*:
=XLOOKUP(D2,A2:A5,B2:B5,"none",2)
=XLOOKUP(D2,A2:A5,B2:B5,"none",-1)
Both returned none, and so did modes 0 and 1. The breakpoints are numbers; the text 100* is not the number 100. If the lookup itself contains * or ?, go to XLOOKUP Wildcard and Partial Match.
Sources
- Microsoft Support: XLOOKUP function (
match_mode0, -1, 1, 2;search_mode2 / -2): https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-88eae8bf5929 - Google Docs Editors Help: XLOOKUP function (same
match_modevalues): https://support.google.com/docs/answer/12405947 - Microsoft Support: VLOOKUP function (
range_lookupTRUE): https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1 - Google Docs Editors Help: VLOOKUP (
is_sortedTRUE): https://support.google.com/docs/answer/3093318