Formualizer Docs

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

ArgumentTypeRequiredDefault
lookup_valueanyRequired—
lookup_arrayrange (range)Required—
return_arrayrange (range)Required—
if_not_foundanyOptional—
match_modenumberOptional0
search_modenumberOptional1

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: 0 exact, -1 exact-or-next-smaller, 1 exact-or-next-larger, 2 wildcard.
  • search_mode: 1 forward, -1 reverse; approximate 2/-2 use linear forward/reverse fallback with ascending/descending sorted input.
  • Exact/wildcard 2/-2 retain forward fallback. Approximate ties follow scan direction.
  • Approximate modes otherwise retain the ascending-input requirement.
  • If return_array is multi-column or multi-row, the matched row/column is returned as a spill.

Error cases

  • if_not_found is optional; if omitted and no match exists, returns #N/A.
  • lookup_array must 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")

Input cells
AB
2101"Ana"
3102"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)

Input cells
ABC
11"East"120
22"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?.

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!.

Implementation

Engine source

On this page