Advanced

Lookup with two criteria in Excel: helper column, XLOOKUP, INDEX/MATCH and SUMIFS

Find a value by two or more criteria in Excel: a helper key column, SUMIFS, XLOOKUP(1,(…)*(…)), INDEX/MATCH, and looking up the intersection of a row and a column.

A payroll table has a separate row for each employee for each month. Question: what is Aziz’s salary in February? Write VLOOKUP("Aziz",…) and Excel returns the first Aziz it meets — the January row — without any error. The report is silently wrong.

Two-criteria lookups come up every day: price lists (product + size), stock (product + branch), sales plans (manager + quarter). Below are four methods — from simplest to most powerful — and when to pick each.

Книга1 - Excel
—☐✕
C8fx=ПРОСМОТРX(A8&"-"&B8;D2:D7;C2:C7)
ABCDE
1EmployeeMonthSalaryKey
2AzizJanuary6 500 000Aziz-January
3DilnozaJanuary7 200 000Dilnoza-January
4JavokhirJanuary5 900 000Javokhir-January
5AzizFebruary6 800 000Aziz-February
6DilnozaFebruary7 000 000Dilnoza-February
7JavokhirFebruary6 100 000Javokhir-February
8AzizFebruary6 800 000
9
Готово
Row 8 is the search row: Aziz + February → 6,800,000. The key column merges two conditions into one

Method 1: a helper key column (any version)

1

Add a column next to the table and join the two criteria into one text: in D2 =A2&"-"&B2 → “Aziz-January”. Fill down. Every row now has a unique key.

Книга1 - Excel
—☐✕
D2fx=A2&"-"&B2
ABCDE
1EmployeeMonthSalaryKey
2AzizJanuary6 500 000Aziz-January1
3DilnozaJanuary7 200 000Dilnoza-January
4AzizFebruary6 800 000Aziz-February
5
Готово

2

Build the key the same way when searching: =ПРОСМОТРX(A8&"-"&B8;D2:D7;C2:C7). In older Excel: =ИНДЕКС(C2:C7;ПОИСКПОЗ(A8&"-"&B8;D2:D7;0)).

3

If you prefer VLOOKUP, put the key column on the left of the table — VLOOKUP only looks to the right: =ВПР(A8&"-"&B8;$A$2:$D$7;4;ЛОЖЬ).

4

The separator (“-”) matters: without it “Ali”+“12” and “Ali1”+“2” both become “Ali12”. Pick a character that never appears in the data.

Method 2: SUMIFS — the simplest when the result is a number

1

If the value you return is a number and each pair occurs once, you don’t even need a helper column: =СУММЕСЛИМН(C2:C7;A2:A7;"Aziz";B2:B7;"February") — “the sum of salaries in rows where Employee = Aziz and Month = February”.

Книга1 - Excel
—☐✕
F3fx=СУММЕСЛИМН(C2:C7;A2:A7;F1;B2:B7;F2)
ABCDEFG
1EmployeeMonthSalaryEmployeeAziz
2AzizJanuary6 500 000MonthFebruary
3DilnozaJanuary7 200 000Salary6 800 000
4JavokhirJanuary5 900 000
5AzizFebruary6 800 000
6DilnozaFebruary7 000 000
7JavokhirFebruary6 100 000
8
Готово
The criteria live in cells (F1, F2) — change them and the result updates instantly

2

Don’t hard-code criteria in the formula — keep them in cells (F1, F2) so one formula works for any employee and month. If the pair isn’t found, SUMIFS returns 0 (not an error); if the pair occurs twice, it returns the sum. See the traps below.

Method 3: XLOOKUP(1, (…)*(…)) — no helper column (Excel 365)

1

Formula: =ПРОСМОТРX(1;(A2:A7=F1)*(B2:B7=F2);C2:C7). Each comparison returns an array of TRUE/FALSE, and multiplying turns them into 1/0: the row where both conditions hold gets 1, all others 0. XLOOKUP then finds the first 1.

Книга1 - Excel
—☐✕
F5fx=D5*E5
ABCDEFG
1EmployeeMonthSalaryA=AzizB=FebruaryProduct
2AzizJanuary6 500 000100
3DilnozaJanuary7 200 000000
4JavokhirJanuary5 900 000000
5AzizFebruary6 800 000111
6DilnozaFebruary7 000 000010
7JavokhirFebruary6 100 000010
8
Готово
What happens “invisibly” inside the formula: only row 5 has both conditions = 1, so the product is 1

2

Need a third condition? Add another factor: *(C2:C7>0). For OR logic, add instead of multiplying: (A2:A7="Aziz")+(A2:A7="Dilnoza").

3

Excel 2019 and older have no XLOOKUP — the same logic with INDEX/MATCH: =ИНДЕКС(C2:C7;ПОИСКПОЗ(1;(A2:A7=F1)*(B2:B7=F2);0)). In older versions confirm it with Ctrl + Shift + Enter instead of Enter (an array formula), or you get #N/A or a wrong result.

4

In Excel 365 you can also build the key inside an array: =ПРОСМОТРX(F1&"-"&F2;A2:A7&"-"&B2:B7;C2:C7) — method 1 without the helper column.

Pro level: the intersection of a row and a column (two-way lookup)

Data is often not “long” but “wide”: employees in rows, months in columns. Then the two criteria are a row and a column. The classic solution gives INDEX two MATCHes — one finds the row number, the other the column number:

=ИНДЕКС(B2:D4;ПОИСКПОЗ(B6;A2:A4;0);ПОИСКПОЗ(B7;B1:D1;0))

In Excel 365, nest XLOOKUPs: =ПРОСМОТРX(B6;A2:A4;ПРОСМОТРX(B7;B1:D1;B2:D4)) — the inner one returns the month column, the outer one finds the employee in it.

If you need several results (say, every month for Aziz), use FILTER: =ФИЛЬТР(C2:C7;(A2:A7="Aziz")*(C2:C7>6000000)) — matching rows spill down.

Книга1 - Excel
—☐✕
B8fx=ИНДЕКС(B2:D4;ПОИСКПОЗ(B6;A2:A4;0);ПОИСКПОЗ(B7;B1:D1;0))
ABCDE
1EmployeeJanuaryFebruaryMarch
2Aziz6 500 0006 800 0007 000 000
3Dilnoza7 200 0007 000 0007 300 000
4Javokhir5 900 0006 100 0006 200 000
5
6Employee:Dilnoza
7Month:March
8Salary:7 300 000
9
Готово
MATCH(B6,…) = row 2, MATCH(B7,…) = column 3 → INDEX returns the intersection: 7,300,000

Try it in the simulator

Type =A2&"-"&B2 in D2 and fill down to D7. Then type =ПРОСМОТРX(A9&"-"&B9;D2:D7;C2:C7) in C9. To check, type =СУММЕСЛИМН(C2:C7;A2:A7;A9;B2:B7;B9) in D9 — both should return 6800000. Try changing A9 or B9.

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1EmployeeMonthSalaryKey
2AzizJanuary6500000
3DilnozaJanuary7200000
4JavokhirJanuary5900000
5AzizFebruary6800000
6DilnozaFebruary7000000
7JavokhirFebruary6100000
8
9AzizFebruary
10
11
12
13
Лист1
Готово

Has ExcelLab been useful?

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

Support us
Previous

151 / 154