How-to recipes · Lookups
How to look up a value with two criteria in Excel
Find a value that matches two conditions, such as rep and month, with XLOOKUP, INDEX/MATCH for Excel 2016, SUMIFS or a helper key column.
A normal lookup searches one column: find the price for product code P-103. Real data is often organised so that one column is not enough. A monthly sales table has one row per rep per month, so searching for "Ben" finds his January row, which is not what you asked for. You need the row where the rep is Ben and the month is February. This recipe shows the modern formula, the classic INDEX/MATCH version for older Excel, and two simpler workarounds.
The example data
Sales by rep and month in A1:C7. The criteria are typed in F1 (rep) and F2 (month) so the formula is reusable. The answer we expect for Ben in February is 5100.
Microsoft 365 and Excel 2021: XLOOKUP with multiplied conditions
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Rep | Month | Sales | Rep | Ben | |
| 2 | Ana | Jan | 4200 | Month | Feb | |
| 3 | Ben | Jan | 3900 | 5100 | ||
| 4 | Ana | Feb | 4600 | |||
| 5 | Ben | Feb | 5100 | |||
| 6 | Ana | Mar | 3800 | |||
| 7 | Ben | Mar | 4700 |
Only row 5 has both Ben and Feb, so XLOOKUP returns 5100 from C5.
Result: 5100
How the trick works:
(A2:A7=F1)compares every rep with "Ben" and gives {FALSE;TRUE;FALSE;TRUE;FALSE;TRUE}.(B2:B7=F2)does the same for the month: {FALSE;FALSE;TRUE;TRUE;FALSE;FALSE}.- Multiplying the two arrays turns TRUE into 1 and FALSE into 0, and a row is 1 only when both tests are true: {0;0;0;1;0;0}.
- XLOOKUP searches that array for the value 1 and returns the item in the same position of C2:C7.
You can add a third condition by multiplying another test, for example *(D2:D7=F3). For OR logic (either condition) use + and search for a value greater than zero with a different approach, such as FILTER.
Excel 2016 and 2019: INDEX and MATCH
The same idea works with INDEX and MATCH:
=INDEX(C2:C7,MATCH(1,(A2:A7=F1)*(B2:B7=F2),0)){=...}. If you press only Enter you get #N/A or a wrong value. Microsoft 365 does not need this.If you prefer to avoid Ctrl+Shift+Enter, wrap the array in another INDEX, which forces Excel to evaluate it as an array: =INDEX(C2:C7,MATCH(1,INDEX((A2:A7=F1)*(B2:B7=F2),0),0)).
Simple alternative 1: SUMIFS for numbers
When the result is a number and each combination occurs only once, SUMIFS is the easiest formula to read and needs no array tricks in any version:
=SUMIFS(C2:C7,A2:A7,F1,B2:B7,F2)It returns 5100 too. Be aware of two differences: if no row matches, SUMIFS returns 0 instead of an error, which can hide a typing mistake; and if two rows match, it adds them together instead of returning the first.
Simple alternative 2: a helper key column
Insert a column that joins the two criteria into one key, then do an ordinary one-column lookup. Here column A holds =B2&"|"&C2 (giving keys such as Ana|Jan) and the lookup searches for the joined criteria:
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Key | Rep | Month | Sales | Find | |
| 2 | Ana|Jan | Ana | Jan | 4200 | Ben|Feb | |
| 3 | Ben|Jan | Ben | Jan | 3900 | 5100 | |
| 4 | Ana|Feb | Ana | Feb | 4600 | ||
| 5 | Ben|Feb | Ben | Feb | 5100 | ||
| 6 | Ana|Mar | Ana | Mar | 3800 | ||
| 7 | Ben|Mar | Ben | Mar | 4700 |
Column A holds the formula =B2&"|"&C2 copied down, which shows keys such as Ana|Jan. The search finds Ben|Feb in row 5.
Result: 5100
The separator | prevents false matches: without it, "Ann" + "aJan" and "Anna" + "Jan" would both become AnnaJan. The helper column also makes the lookup fast on large tables, because VLOOKUP compares one text instead of building two arrays.
Pitfalls
- Dates as criteria: if column B holds real dates, compare with a real date (
=DATE(2026,2,1)) or the month number (MONTH(B2:B7)=2), not with text like "Feb". - Spaces and text-numbers stop a match just as in any lookup. If you get
#N/A, test each condition alone, for example=SUM(--(A2:A7=F1))to see how many reps match. - Whole-column references such as
A:Ainside the multiplied arrays make the formula calculate a million rows. Use exact ranges or a table. - If several rows match, XLOOKUP and INDEX/MATCH return the first one. To return them all, see How to return multiple matches in Excel.