XMATCH: Position, Then Value
About this lesson
XMATCH returns the position of a value in a range, exact by default. It has the same match modes as XLOOKUP. INDEX reads whatever sits at that position in another range.
- find a value's position with XMATCH and read another column at it.
- find the first value at or above a target with match mode 1.
The idea
MATCH with the trailing 0 forgotten is exact-by-default XMATCH. The position it returns is a number. A number can be handed to INDEX over any column of the same table. That is how a value found in one column reads a value from another.
Match mode 1 is the one to know beyond exact. On a sorted column it finds the first value at or above a target. The row where a threshold is crossed, the first bundle big enough, the first date after a deadline. XLOOKUP does the same in one call when you want the value. XMATCH is for when you want the row.
The mistake to watch for
Searching the wrong column. XMATCH for a name in the sales column returns #N/A, which is the true answer. IFNA turns it into words. And on a sorted column, match mode 1 and -1 answer opposite questions: first at or above, against last at or below. The wrong sign is off by one row on every line, without an error.
Where this comes up again
This lesson needs JavaScript to run. Everything below is the lesson in full, but you cannot type into the grid or be marked.
In E2, find which position Cal holds in the list of reps, with XMATCH.
To begin, type it exactly:
=XMATCH(D2,A2:A7)
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Rep | Sales | Look for | Position | |||
| 2 | Bea | 180 | Cal | ||||
| 3 | Gus | 240 | Ade | ||||
| 4 | Cal | 310 | |||||
| 5 | Ade | 460 | Target | 500 | |||
| 6 | Fay | 520 | |||||
| 7 | Hal | 700 | |||||
| 8 |
Every step
-
In
E2, find which position Cal holds in the list of reps, withXMATCH. To begin, type it exactly:=XMATCH(D2,A2:A7). -
A position is only useful when something reads it. In
E3, find Ade's sales by feedingXMATCH's answer intoINDEXover the sales column. -
In
E4, search the sales column, not the names, for the name inD2. Wrap theXMATCHinIFNAso a miss reads Not there. -
The sales are sorted ascending. In
E6, find the position of the first figure at or above the target inE5. UseXMATCHwith a match mode of 1. -
In
E7, write a formula usingINDEXandXMATCH. It should give the name of the first rep at or above the target. -
The trap. Somebody wrote the threshold search with -1 instead of 1:
=XMATCH(E5,B2:B7,-1). Read it and say what position it returns.