ReferenceFunctionsLookup Functions
XMATCH
XMATCH: Returns the 1-based position of a value in a one-dimensional lookup array.
Summary
XMATCH extends MATCH with explicit search direction and wildcard mode.
Remarks
- Defaults:
match_mode=0(exact),search_mode=1(first-to-last). match_mode:0exact,-1exact-or-next-smaller,1exact-or-next-larger,2wildcard.search_mode:1forward,-1reverse,2ascending binary intent,-2descending binary intent.lookup_arraymust be a single row or single column, otherwise returns#VALUE!.- Not found returns
#N/A.
Examples
Exact match position
Grid
| Cell | Value | |
|---|---|---|
Formula
=
Result
Not evaluated yet.
Expected
2
Reverse search finds last duplicate
Grid
| Cell | Value | |
|---|---|---|
Formula
=
Result
Not evaluated yet.
Expected
3
Related functions
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.
Runtime metadata
Category
Lookup
Signature
XMATCH(arg1: Any, arg2: Range (Range), arg3?: Number, arg4?…: Number)Arity
min 2, max variadic
Arguments
arg1Any · Scalar
arg2by-refRange · Range
arg3optionaldefaultNumber · Scalar · coercion NumberLenientText
arg4optionaldefaultNumber · Scalar · coercion NumberLenientText
Caps
PURELOOKUP
Source