Excel tutorial
/

Functions

Advanced

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?

Книга1 - Excel
—☐✕
E2fx=ПОИСКПОЗX(E1;A2:A7)
ABCDEF
1ClientAmountClient:Dilnoza
2Aziz250 000First order:2
3Dilnoza1180 000
4Javohir320 000
5Dilnoza410 000
6Malika150 000
7Aziz275 000
8
Готово
No third argument needed: XMATCH matches exactly by default and returns the first Dilnoza it meets (1) — position 2

Syntax

=ПОИСКПОЗX(lookup_value; lookup_array; [match_mode]; [search_mode])

  • lookup_value — what to find.
  • lookup_array — a single column or row.
  • match_mode — 0 exact (default); -1 exact or next smaller; 1 exact or next larger; 2 wildcards (*, ?, ~).
  • search_mode — 1 from the first item (default); -1 from the last; 2 binary search in a list sorted ascending; -2 binary 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, -1 means “smallest value not less than” and requires descending order. In XMATCH, -1 means “exact or next smaller” and 1 means “exact or next larger”. Copy the numbers across unchanged and the result may come out reversed.
  • Sorting. XMATCH’s -1 and 1 modes work correctly on unsorted lists too.
  • Wildcards. MATCH understands them on its own with type 0; XMATCH only with match_mode = 2.
  • Searching from the end exists only in XMATCH.

Writing XMATCH step by step

1

Select the result cell (E2). Формулы → Ссылки и массивы → XMATCH.

Книга1 - Excel
—☐✕
ФайлГлавнаяВставкаРазметка страницыФормулыДанныеРецензированиеВидСправка
Вставить функциюАвтосуммаФинансовыеЛогическиеТекстовыеДата и времяСсылки и массивыМатематические
Библиотека функций
Диспетчер имён
Определённые имена
E2fx
ABCDEF
1ClientAmountClient:Dilnoza
2Aziz250000First order:
3Dilnoza180000
4Javohir320000
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.

Книга1 - Excel
—☐✕
E2fx
ABCDEF
1ClientAmountClient:Dilnoza
2Aziz250000First order:
3Dilnoza180000
4Javohir320000
5Dilnoza410000
6Malika150000
7Aziz275000
8
ГотовоКоличество: 6

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.

Книга1 - Excel
—☐✕
E4fx=ИНДЕКС(B2:B7;E3)
ABCDEF
1ClientAmountClient:Dilnoza
2Aziz250 000First order:2
3Dilnoza180 000Latest order:4
4Javohir320 000Latest amount:410 000
5Dilnoza1410 000
6Malika150 000
7Aziz275 000
8
Готово
E3: =XMATCH(E1,A2:A7,0,-1) → 4. The search ran from the bottom, so Dilnoza’s latest order (1) was found

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.

Книга1 - Excel
—☐✕
E3fx=ИНДЕКС(A2:A5;E2)
ABCDEF
1TruckLoad, tCargo, t:3,21
2Isuzu52Position:1
3Damas0,5Truck:Isuzu
4Kamaz10
5Labo1
6
Готово
E2: =XMATCH(E1,B2:B5,1) → 1. For 3.2 t (1) the next larger value is 5 t (2) — the Isuzu

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.
Книга1 - Excel
—☐✕
B8fx=ИНДЕКС(B2:D5;ПОИСКПОЗX(B6;A2:A5);ПОИСКПОЗX(B7;B1:D1))
ABCDE
1CityStandardFastExpress
2Tashkent15 00025 00040 000
3Samarkand25 00035 00055 000
4Bukhara30 00042 00065 000
5Fergana28 00039 00060 000
6City:Bukhara
7Type:Fast
8Price:42 000
9
Готово
Delivery price, soums. Bukhara is row 3, Fast is column 2: INDEX returns 42,000 where they meet

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.

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1CityStandardFastExpress
2Tashkent150002500040000
3Samarkand250003500055000
4Bukhara300004200065000
5Fergana280003900060000
6City:Bukhara
7Type:Fast
8Price:
9
10
11
12
Лист1
Готово

Has ExcelLab been useful?

Support the project and help us release new lessons and exercises.

Support us
Previous

99 / 154