Formualizer Docs

XMATCH

Returns the 1-based position of a value in a one-dimensional lookup array.

XMATCH extends MATCH with explicit search direction and wildcard mode.

The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.

Syntax

=XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])

Arguments

ArgumentTypeRequiredDefault
lookup_valueanyRequired—
lookup_arrayrange (range)Required—
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, 2 ascending binary intent, -2 descending binary intent.

Error cases

  • lookup_array must be a single row or single column, otherwise returns #VALUE!.
  • Not found returns #N/A.

Examples

Return the one-based position of an exact match with the default settings.

Formula =XMATCH("Bo",{"Ana";"Bo";"Cy"})

Expected result 2

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 from the end to find the last exact match.

Formula =XMATCH("Bo",{"Bo";"Ana";"Bo"},0,-1)

Expected result 3

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

The only possible match in a one-item array has position one.

Formula =XMATCH("Bo",{"Bo"})

Expected result 1

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 key has no matching position.

Formula =XMATCH("Dee",{"Ana";"Bo";"Cy"})

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 match position

Formula =XMATCH("beta",A1:A3)

Input cells
A
1"alpha"
2"beta"
3"gamma"

Expected result 2

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

Reverse search finds last duplicate

Formula =XMATCH(7,A1:A3,0,-1)

Input cells
A
17
29
37

Expected result 3

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 search_mode values affect duplicate matches?

search_mode=1 returns the first qualifying match, while search_mode=-1 scans from the end and returns the last qualifying match.

When do binary-intent search modes (2 or -2) return #N/A?

For approximate modes they require sorted data in the expected direction; unsorted arrays are treated as no valid match and return #N/A.

Implementation

Engine source

On this page