XLOOKUP
Looks up a value in one array and returns the aligned value from another array.
XLOOKUP supports exact, approximate, and wildcard matching with forward or reverse search.
The Formualizer engine in this repository at 0.16.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.
Syntax
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
lookup_value | any | Required | — |
lookup_array | range (range) | Required | — |
return_array | range (range) | Required | — |
if_not_found | any | Optional | — |
match_mode | number | Optional | 0 |
search_mode | number | Optional | 1 |
Remarks
- Defaults:
match_mode=0(exact),search_mode=1(first-to-last). - In exact and wildcard modes, a blank lookup value selects only a blank candidate; numeric zero and empty text remain distinct.
match_mode:0exact,-1exact-or-next-smaller,1exact-or-next-larger,2wildcard.search_mode:1forward,-1reverse; approximate2/-2use linear forward/reverse fallback with ascending/descending sorted input.- Exact/wildcard
2/-2retain forward fallback. Approximate ties follow scan direction. - Approximate modes otherwise retain the ascending-input requirement.
- If
return_arrayis multi-column or multi-row, the matched row/column is returned as a spill.
Error cases
if_not_foundis optional; if omitted and no match exists, returns#N/A.lookup_arraymust be 1D. Invalid shape returns#VALUE!.
Examples
Find a name and return the corresponding number.
Formula =XLOOKUP("Bo",{"Ana";"Bo";"Cy"},{10;20;30})
Expected result 20
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Use a custom result for a missing key.
Formula =XLOOKUP("Dee",{"Ana";"Bo";"Cy"},{10;20;30},"No match")
Expected result No match
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Search a one-item array from the end for an exact match.
Formula =XLOOKUP("Bo",{"Bo"},{20},"",0,-1)
Expected result 20
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
A missing lookup without a fallback returns an error.
Formula =XLOOKUP("Dee",{"Ana";"Bo";"Cy"},{10;20;30})
Expected result #N/A
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Exact key lookup with fallback
Formula =XLOOKUP(102,A2:A3,B2:B3,"Missing")
| A | B | |
|---|---|---|
| 2 | 101 | "Ana" |
| 3 | 102 | "Bo" |
Expected result Bo
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Return a full row from a matched key
Formula =XLOOKUP(2,A1:A2,B1:C2)
| A | B | C | |
|---|---|---|---|
| 1 | 1 | "East" | 120 |
| 2 | 2 | "West" | 140 |
Expected result {"West", 140}
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Related functions
FAQ
How do match_mode and search_mode interact?
match_mode controls exact/approximate/wildcard behavior, while search_mode controls scan direction; reverse search (-1) returns the last matching position.
What happens when no match is found?
If if_not_found is provided, XLOOKUP returns that value; otherwise it returns #N/A.
Why do I get #VALUE! from XLOOKUP on valid ranges?
The lookup_array must be one-dimensional (single row or single column); multi-row-and-column lookup ranges return #VALUE!.