Lookups

How to Look Up Using Two Criteria in Excel

How to look up a value using two conditions in Excel, with a helper column, XLOOKUP and INDEX with MATCH, and when SUMIFS is the better choice.

On this page
  1. Option 1: a helper column
  2. Option 2: XLOOKUP with two conditions
  3. Option 3: INDEX with MATCH
  4. Which option to use
  5. When to add up instead of look up

VLOOKUP and XLOOKUP take one lookup value. When a row is identified by two things, such as a region and a product, one value on its own is not enough. Each column repeats, but only the pair is unique. You need to combine the two conditions or test both at once.

The examples below use a sales list on the same sheet. Region is in column A, product in column B and price in column C, with data in rows 2 to 100. The region you want is in F2, the product in G2, and the price should appear in H2.

Option 1: a helper column

Add a column that joins the two values. In column D, filled down, type:

=A2&"|"&B2

The separator keeps combinations apart. Without it, a region of “A1” with the product “Tea” and a region of “A” with the product “1Tea” would join to the same text. Then look up the joined version of your two inputs:

=XLOOKUP(F2&"|"&G2, D2:D100, C2:C100, "Not found")

A helper column works in every version of Excel and is easy to check by eye. The downside is that the column must be filled for each new row, and it adds a column to the sheet.

Option 2: XLOOKUP with two conditions

In Excel 2021 and Microsoft 365, XLOOKUP can test both conditions in one formula:

=XLOOKUP(1, ($A$2:$A$100=F2)*($B$2:$B$100=G2), $C$2:$C$100, "Not found")

Each comparison gives TRUE or FALSE for every row. Multiplying the two results gives 1 only where both are TRUE. XLOOKUP then searches for the 1. In these versions the formula works without any special key combination.

Option 3: INDEX with MATCH

The same test works with INDEX and MATCH:

=INDEX($C$2:$C$100, MATCH(1, ($A$2:$A$100=F2)*($B$2:$B$100=G2), 0))

In Excel 2021 and Microsoft 365 this runs as written. In Excel 2019 and earlier, you need to enter the formula with Ctrl+Shift+Enter, and Excel then wraps it in braces. Without that, the older version does not test every row, and the formula returns an error or the wrong row.

Which option to use

If you have Excel 2021 or Microsoft 365, the XLOOKUP version is the shortest. A helper column is the easiest option for a team that may not know the newer formulas, and it works in every version. INDEX with MATCH gives the same result, and how to use index and match in excel explains its parts.

Text comparisons are exact in these formulas, so a stray space in one list will stop a match. The same cleaning steps used for other lookups apply here.

When to add up instead of look up

A lookup returns one row. If you want to total the matching rows, such as all sales for a region and product, use SUMIFS. It adds every row that meets both conditions, and sumifs with multiple criteria in excel shows how to set it up. If you want every matching row listed, how to use filter function in excel covers that.

The complete guide to lookups

How to Look Up Data in Excel
Read the guide

Keep exploring

Guides from other topics

All topics →