Menu

Excel Lookup with Multiple Criteria: XLOOKUP, INDEX MATCH

=XLOOKUP(1,(A2:A7=E2)*(B2:B7=F2),C2:C7) returns the value from the row where column A matches E2 and column B matches F2. The INDEX MATCH version, a helper column for VLOOKUP, and FILTER for every match.

Every sheet on this page is live: change a number or a formula and it recalculates.

=XLOOKUP(1,(A2:A7=E2)*(B2:B7=F2),C2:C7) returns the price from the row where the product is E2 and the size is F2. Each comparison checks every row, multiplying them gives 1 only where both are true, and XLOOKUP looks for that 1. It needs Excel 2021 or Microsoft 365; the INDEX MATCH version below works in every version.

Price by product and size
G2
ABCDEFG
1ProductSizePriceProductSizePrice
2CoffeeSmall$2.50TeaLarge$3.00
3CoffeeLarge$3.50
4TeaSmall$2.00
5TeaLarge$3.00
6JuiceSmall$3.00
7JuiceLarge$4.00
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Tea and Large meet in row 5, so G2 returns 3.00.PickJuiceandSmall:3.00. Pick Juice and Small: 3.00 again, from another row. Add a fourth argument for the case where no row matches both: =XLOOKUP(1,(A2:A7=E2)*(B2:B7=F2),C2:C7,"No such item").

How the multiplied conditions work

A2:A7=E2 compares every product with E2 and returns six TRUE or FALSE values. Multiplying two such lists turns TRUE into 1 and FALSE into 0, and a row is 1 only if it is 1 in both. Column D shows that list, spilled from one formula.

The array XLOOKUP searches
D2
ABCDEFG
1ProductSizePriceBoth matchProductSize
2CoffeeSmall$2.500TeaLarge
3CoffeeLarge$3.500
4TeaSmall$2.000
5TeaLarge$3.001
6JuiceSmall$3.000
7JuiceLarge$4.000
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Only D5 is 1. Change F2 or G2 and the 1 moves. Every extra criterion is one more *(range=value), and the conditions do not have to be equality: *(C2:C7<3) adds "price below 3". Every range must cover the same rows (A2:A7, B2:B7, C2:C7): if the return range has a different size from the conditions, XLOOKUP returns #VALUE!.

INDEX MATCH with multiple criteria

For Excel 2019 and older, MATCH can search the same array for the 1 and INDEX returns the price from that position.

Two criteria with INDEX and MATCH
G2
ABCDEFG
1ProductSizePriceProductSizePrice
2CoffeeSmall$2.50CoffeeLarge$3.50
3CoffeeLarge$3.50
4TeaSmall$2.00
5TeaLarge$3.00
6JuiceSmall$3.00
7JuiceLarge$4.00
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Coffee and Large is position 2 of the array, and INDEX returns $3.50. In Excel 2019 and older this is an array formula: press Ctrl+Shift+Enter (Cmd+Shift+Enter on a Mac) instead of Enter, and Excel shows it inside curly braces. Pressing plain Enter there usually returns #N/A or #VALUE!. In Excel 365, Enter is enough. The single-criterion form is on the INDEX and MATCH page.

Join the criteria into one key

The other way is to turn two criteria into one by joining them. VLOOKUP needs the joined values in a helper column at the start of the table (the VLOOKUP page shows that version). XLOOKUP can join the ranges inside the formula, so no helper column is needed.

Join product and size into one key
G2
ABCDEFG
1ProductSizePriceProductSizePrice
2CoffeeSmall$2.50JuiceLarge$4.00
3CoffeeLarge$3.50
4TeaSmall$2.00
5TeaLarge$3.00
6JuiceSmall$3.00
7JuiceLarge$4.00
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

A2:A7&"|"&B2:B7 builds six keys such as Juice|Large, and XLOOKUP finds Juice|Large among them: $4.00. Put a separator between the parts. Without it, "AB" and "C" join to the same "ABC" as "A" and "BC", and the lookup can return the wrong row.

If the value you want is a number and each combination appears once, SUMIFS gives the same answer with no array at all: =SUMIFS(C2:C7,A2:A7,E2,B2:B7,F2). It returns 0 instead of an error when nothing matches, which can hide a typo.

Return every match with FILTER

XLOOKUP and INDEX MATCH return the first matching row. When several rows match and you want all of them, use FILTER with the same conditions.

All North phone orders
F2
ABCDEFG
1RegionProductQuarterSalesMatches
2NorthLaptopQ1120Q1210
3NorthPhoneQ1210Q2225
4SouthLaptopQ195Q3240
5NorthPhoneQ2225
6SouthPhoneQ2180
7NorthLaptopQ2135
8NorthPhoneQ3240
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Three rows are North and Phone, so F2 spills their quarters and sales into F2:G4. Change A3 to South and the list shrinks to two. If no row matches, FILTER returns #CALC!; a third argument such as "None" shows text instead. More options are on the FILTER page.

Practice: three criteria

Sales by region, product and quarter
G4
ABCDEFG
1RegionProductQuarterSalesRegionSouth
2NorthLaptopQ1120ProductLaptop
3NorthLaptopQ2135QuarterQ2
4NorthPhoneQ1210Sales
5SouthLaptopQ195
6SouthPhoneQ2180
7SouthLaptopQ2110
8NorthPhoneQ2225
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Your turn: Return in G4 the sales for the region in G1, the product in G2 and the quarter in G3.

Frequently Asked Questions

How do I use XLOOKUP with multiple criteria?

Multiply one comparison per criterion and look up 1: =XLOOKUP(1,(A2:A7=E2)*(B2:B7=F2),C2:C7). Each comparison gives TRUE or FALSE per row, the product is 1 only where all are TRUE, and XLOOKUP returns the first such row.

How do I do INDEX MATCH with two criteria?

Use the same multiplied conditions inside MATCH: =INDEX(C2:C7,MATCH(1,(A2:A7=E2)*(B2:B7=F2),0)). In Excel 2019 and older, confirm it with Ctrl+Shift+Enter (Cmd+Shift+Enter on a Mac).

Can VLOOKUP use two criteria?

Not directly. Add a helper column at the start of the table that joins the two values, such as =A2&"|"&B2, then look up the joined value: =VLOOKUP(E2&"|"&F2,helper_table,col,FALSE).

Can SUMIFS replace a lookup with two criteria?

Yes, when the value is a number and each combination appears once: =SUMIFS(C2:C7,A2:A7,E2,B2:B7,F2). It returns 0 instead of #N/A when no row matches, and adds the values together if a combination appears twice.

How do I look up with OR criteria?

Add the conditions instead of multiplying them: (A2:A7="Tea")+(A2:A7="Juice") is 1 or more where either is true. Look up a value greater than 0, for example with =XLOOKUP(TRUE,((A2:A7="Tea")+(A2:A7="Juice"))>0,C2:C7).

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED