How to use XMATCH in Excel: the next generation of MATCH
XMATCH (Excel 2021/365) finds a value’s position: exact by default, searches from the end, approximate match without sorting. How it differs from MATCH.
XMATCH is the upgraded MATCH in Excel 2021 and Microsoft 365. Its job is the same: return the position of a value in a list. But it fixes the spots where MATCH most often leads to mistakes:
- it matches exactly by default (MATCH defaults to approximate);
- it can search from the end — a client’s latest order, a product’s latest price;
- approximate matching doesn’t require sorting.
Example: in an order log, at which position did Dilnoza place her first order?
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Client | Amount | Client: | Dilnoza | ||
| 2 | Aziz | 250 000 | First order: | 2 | ||
| 3 | Dilnoza1 | 180 000 | ||||
| 4 | Javohir | 320 000 | ||||
| 5 | Dilnoza | 410 000 | ||||
| 6 | Malika | 150 000 | ||||
| 7 | Aziz | 275 000 | ||||
| 8 |
Syntax
=ПОИСКПОЗX(lookup_value; lookup_array; [match_mode]; [search_mode])
lookup_value— what to find.lookup_array— a single column or row.match_mode—0exact (default);-1exact or next smaller;1exact or next larger;2wildcards (*,?,~).search_mode—1from the first item (default);-1from the last;2binary search in a list sorted ascending;-2binary search in a list sorted descending.
MATCH vs XMATCH: what’s different
- The default.
=ПОИСКПОЗ(E1;A2:A7)is approximate (1),=ПОИСКПОЗX(E1;A2:A7)is exact (0). When you switch from MATCH, this difference changes the result. - -1 and 1 mean different things! In MATCH,
-1means “smallest value not less than” and requires descending order. In XMATCH,-1means “exact or next smaller” and1means “exact or next larger”. Copy the numbers across unchanged and the result may come out reversed. - Sorting. XMATCH’s
-1and1modes work correctly on unsorted lists too. - Wildcards. MATCH understands them on its own with type
0; XMATCH only withmatch_mode= 2. - Searching from the end exists only in XMATCH.
Writing XMATCH step by step
1
Select the result cell (E2). Формулы → Ссылки и массивы → XMATCH.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Client | Amount | Client: | Dilnoza | ||
| 2 | Aziz | 250000 | First order: | |||
| 3 | Dilnoza | 180000 | ||||
| 4 | Javohir | 320000 | ||||
| 5 |
2
Lookup_value — E1, Lookup_array — A2:A7. Leave Match_mode and Search_mode empty: exact match, top to bottom. Click OK — the result is 2.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Client | Amount | Client: | Dilnoza | ||
| 2 | Aziz | 250000 | First order: | |||
| 3 | Dilnoza | 180000 | ||||
| 4 | Javohir | 320000 | ||||
| 5 | Dilnoza | 410000 | ||||
| 6 | Malika | 150000 | ||||
| 7 | Aziz | 275000 | ||||
| 8 |
3
Now find the latest order: type =ПОИСКПОЗX(E1;A2:A7;0;-1) in E3 — you get 4. The formula =ИНДЕКС(B2:B7;E3) in E4 fetches that order’s amount.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Client | Amount | Client: | Dilnoza | ||
| 2 | Aziz | 250 000 | First order: | 2 | ||
| 3 | Dilnoza | 180 000 | Latest order: | 4 | ||
| 4 | Javohir | 320 000 | Latest amount: | 410 000 | ||
| 5 | Dilnoza1 | 410 000 | ||||
| 6 | Malika | 150 000 | ||||
| 7 | Aziz | 275 000 | ||||
| 8 |
Example: the smallest truck that fits (match_mode 1)
The warehouse has 3.2 tonnes of cargo. The fleet list is not sorted by capacity. You need the truck with the smallest capacity that is at least 3.2 tonnes.
=ПОИСКПОЗX(E1;B2:B5;1) finds the smallest value among those ≥ 3.2 (that is 5) and returns its position. Then =ИНДЕКС(A2:A5;E2) gives the truck’s name.
With MATCH you would first have to sort the list in descending order.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Truck | Load, t | Cargo, t: | 3,21 | ||
| 2 | Isuzu | 52 | Position: | 1 | ||
| 3 | Damas | 0,5 | Truck: | Isuzu | ||
| 4 | Kamaz | 10 | ||||
| 5 | Labo | 1 | ||||
| 6 |
Pro level: two-way lookup with INDEX + XMATCH
Use XMATCH twice — for INDEX’s row number and its column number:
=ИНДЕКС(B2:D5;ПОИСКПОЗX(B6;A2:A5);ПОИСКПОЗX(B7;B1:D1))
It is shorter than INDEX/MATCH — no 0 to type.
Two more features:
- Several values at once.
=ПОИСКПОЗX(D2:D4;A2:A7)returns the positions of three names in one formula — the result spills down. - A large sorted list. In a list of 100,000 IDs,
=ПОИСКПОЗX(E1;A2:A100001;0;2)uses binary search and answers instantly.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | City | Standard | Fast | Express | |
| 2 | Tashkent | 15 000 | 25 000 | 40 000 | |
| 3 | Samarkand | 25 000 | 35 000 | 55 000 | |
| 4 | Bukhara | 30 000 | 42 000 | 65 000 | |
| 5 | Fergana | 28 000 | 39 000 | 60 000 | |
| 6 | City: | Bukhara | |||
| 7 | Type: | Fast | |||
| 8 | Price: | 42 000 | |||
| 9 |
Try it in the simulator
Type =ИНДЕКС(B2:D5;ПОИСКПОЗX(B6;A2:A5);ПОИСКПОЗX(B7;B1:D1)) in B8. Then type “Samarkand” in B6 and “Express” in B7 and watch the price change. Type =ПОИСКПОЗX(B6;A2:A5) in E2 to see the city’s position on its own.
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | City | Standard | Fast | Express | ||||||||||||||||||||
| 2 | Tashkent | 15000 | 25000 | 40000 | ||||||||||||||||||||
| 3 | Samarkand | 25000 | 35000 | 55000 | ||||||||||||||||||||
| 4 | Bukhara | 30000 | 42000 | 65000 | ||||||||||||||||||||
| 5 | Fergana | 28000 | 39000 | 60000 | ||||||||||||||||||||
| 6 | City: | Bukhara | ||||||||||||||||||||||
| 7 | Type: | Fast | ||||||||||||||||||||||
| 8 | Price: | |||||||||||||||||||||||
| 9 | ||||||||||||||||||||||||
| 10 | ||||||||||||||||||||||||
| 11 | ||||||||||||||||||||||||
| 12 |
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.