Sub topic 3
Approximate Match for Tiers and Bands
Assume you can enter formulas, copy them, and use absolute references such as $E$2. XLOOKUP searches one range and returns a related value from another range.
Approximate match for tiers and bands
Use match_mode -1 when your table contains lower bounds. XLOOKUP returns the largest bound that is less than or equal to the lookup value.
=XLOOKUP(B2, $E$2:$E$6, $F$2:$F$6, "Below minimum", -1)If E2:E6 contains 0, 60, 70, 80, 90 and F2:F6 contains F, D, C, B, A, a score of 85 returns B. The bounds must be sorted in ascending order.
Use match_mode 1 when the table contains upper limits. It returns the smallest value that is greater than or equal to the lookup value.
=XLOOKUP(B2, $E$2:$E$6, $F$2:$F$6, "Above range", 1)Wildcard matching for partial text
Set match_mode to 2 to enable wildcards. An asterisk matches any number of characters.
=XLOOKUP("*"&E2&"*", A2:A10, C2:C10, "No match", 2)This returns the first row whose text contains the value in E2.
Searching first to last or last to first
XLOOKUP normally returns the first match. Set search_mode to -1 to search from the last item upward.
=XLOOKUP(E2, A2:A100, C2:C100, "None", 0, -1)This is useful when repeated records are ordered from oldest to newest and you need the latest match.
Two-way lookups with nested XLOOKUP
Nest one XLOOKUP inside another to select both a row and a column.
=XLOOKUP(G1, A2:A6, XLOOKUP(G2, B1:E1, B2:E6))The inner lookup selects a column by its header. The outer lookup selects a row by its label.
Binary search on sorted data
search_mode 2 enables binary search. It can improve performance on large ranges, but the lookup range must be sorted in ascending order.
=XLOOKUP(E2, A2:A1000, B2:B1000, "Not found", -1, 2)Compatibility and comparison
XLOOKUP is easier to read and can search in either direction. Older Excel versions may require VLOOKUP or INDEX with MATCH.
| Need | XLOOKUP | Older alternative |
|---|---|---|
| Return a related value | `XLOOKUP` | `VLOOKUP` or `INDEX`/`MATCH` |
| Search from the last match | `search_mode -1` | More complex formula |
Exercise
Which settings return the last matching record?
Show answer
Use an exact match with match_mode 0 and set search_mode to -1.