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.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Employee | Month | Salary | Key | |
| 2 | Aziz | January | 6 500 000 | Aziz-January | |
| 3 | Dilnoza | January | 7 200 000 | Dilnoza-January | |
| 4 | Javokhir | January | 5 900 000 | Javokhir-January | |
| 5 | Aziz | February | 6 800 000 | Aziz-February | |
| 6 | Dilnoza | February | 7 000 000 | Dilnoza-February | |
| 7 | Javokhir | February | 6 100 000 | Javokhir-February | |
| 8 | Aziz | February | 6 800 000 | ||
| 9 |
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.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Employee | Month | Salary | Key | |
| 2 | Aziz | January | 6 500 000 | Aziz-January1 | |
| 3 | Dilnoza | January | 7 200 000 | Dilnoza-January | |
| 4 | Aziz | February | 6 800 000 | Aziz-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”.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Employee | Month | Salary | Employee | Aziz | ||
| 2 | Aziz | January | 6 500 000 | Month | February | ||
| 3 | Dilnoza | January | 7 200 000 | Salary | 6 800 000 | ||
| 4 | Javokhir | January | 5 900 000 | ||||
| 5 | Aziz | February | 6 800 000 | ||||
| 6 | Dilnoza | February | 7 000 000 | ||||
| 7 | Javokhir | February | 6 100 000 | ||||
| 8 |
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.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Employee | Month | Salary | A=Aziz | B=February | Product | |
| 2 | Aziz | January | 6 500 000 | 1 | 0 | 0 | |
| 3 | Dilnoza | January | 7 200 000 | 0 | 0 | 0 | |
| 4 | Javokhir | January | 5 900 000 | 0 | 0 | 0 | |
| 5 | Aziz | February | 6 800 000 | 1 | 1 | 1 | |
| 6 | Dilnoza | February | 7 000 000 | 0 | 1 | 0 | |
| 7 | Javokhir | February | 6 100 000 | 0 | 1 | 0 | |
| 8 |
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.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Employee | January | February | March | |
| 2 | Aziz | 6 500 000 | 6 800 000 | 7 000 000 | |
| 3 | Dilnoza | 7 200 000 | 7 000 000 | 7 300 000 | |
| 4 | Javokhir | 5 900 000 | 6 100 000 | 6 200 000 | |
| 5 | |||||
| 6 | Employee: | Dilnoza | |||
| 7 | Month: | March | |||
| 8 | Salary: | 7 300 000 | |||
| 9 |
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.
| 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 | Employee | Month | Salary | Key | ||||||||||||||||||||
| 2 | Aziz | January | 6500000 | |||||||||||||||||||||
| 3 | Dilnoza | January | 7200000 | |||||||||||||||||||||
| 4 | Javokhir | January | 5900000 | |||||||||||||||||||||
| 5 | Aziz | February | 6800000 | |||||||||||||||||||||
| 6 | Dilnoza | February | 7000000 | |||||||||||||||||||||
| 7 | Javokhir | February | 6100000 | |||||||||||||||||||||
| 8 | ||||||||||||||||||||||||
| 9 | Aziz | February | ||||||||||||||||||||||
| 10 | ||||||||||||||||||||||||
| 11 | ||||||||||||||||||||||||
| 12 | ||||||||||||||||||||||||
| 13 |
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.