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.

Intermediate XLOOKUP INDEX MATCH SUMIFS VLOOKUP FILTER

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

F3fx=XLOOKUP(1,(A2:A7=F1)*(B2:B7=F2),C2:C7,"Not found")
ABCDEF
1RepMonthSalesRepBen
2AnaJan4200MonthFeb
3BenJan39005100
4AnaFeb4600
5BenFeb5100
6AnaMar3800
7BenMar4700

Only row 5 has both Ben and Feb, so XLOOKUP returns 5100 from C5.

Result: 5100

How the trick works:

  1. (A2:A7=F1) compares every rep with "Ben" and gives {FALSE;TRUE;FALSE;TRUE;FALSE;TRUE}.
  2. (B2:B7=F2) does the same for the month: {FALSE;FALSE;TRUE;TRUE;FALSE;FALSE}.
  3. 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}.
  4. 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:

Formula
=INDEX(C2:C7,MATCH(1,(A2:A7=F1)*(B2:B7=F2),0))
Watch out. In Excel 2016 and 2019 this is an array formula: confirm it with Ctrl+Shift+Enter instead of Enter. Excel shows it wrapped in curly braces {=...}. 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:

Formula
=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:

F3fx=VLOOKUP("Ben|Feb",A2:D7,4,FALSE)
ABCDEF
1KeyRepMonthSalesFind
2Ana|JanAnaJan4200Ben|Feb
3Ben|JanBenJan39005100
4Ana|FebAnaFeb4600
5Ben|FebBenFeb5100
6Ana|MarAnaMar3800
7Ben|MarBenMar4700

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:A inside 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.
Tip. The full comparison of lookup functions, with their strengths and weaknesses, is in Lookup guide: VLOOKUP vs INDEX/MATCH vs XLOOKUP. For a lookup that searches a column to the left of the result, see How to look up a value to the left in Excel.
⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 15 KB

More how-to recipes