1XLOOKUP with a joined key
=XLOOKUP(F2&G2,A2:A9&B2:B9,C2:C9)
- Put the product in F2 and the size in G2.
- In H2 type =XLOOKUP(F2&G2,A2:A9&B2:B9,C2:C9).
- Add a fourth argument such as "No price" to control what shows when the pair is missing.
Look up a value that depends on two columns, such as product and size, with XLOOKUP and a joined key, INDEX and MATCH, or SUMIFS.
A price list has a row for every product in every size. The product name alone does not identify a price, and neither does the size. You need both together.
VLOOKUP looks at one column. The classic workaround is a helper column that joins the two keys, then a lookup on that. In current Excel you do not need the helper: XLOOKUP accepts an array, so you can build the combined key inside the formula.
=XLOOKUP(F2&G2, A2:A9&B2:B9, C2:C9) joins the wanted product and size, joins the product and size columns row by row, and finds the position where the two match. It returns the price from the same position in column C.
A joined key can produce false matches when the pieces blur together. "AB" and "C" gives the same text as "A" and "BC". If your keys can do that, join them with a separator that never appears in the data, such as a pipe.
If the value you are returning is a number and each pair is unique, SUMIFS is an easy alternative: it sums the matching row, which is the price itself. It returns 0 rather than an error when nothing matches, so use it with care.
Older workbooks use INDEX and MATCH with a multiplied test: MATCH(1,(A2:A9=F2)*(B2:B9=G2),0). It does the same thing and works in every version. See the Lookups track for the full set of patterns.
=XLOOKUP(F2&G2,A2:A9&B2:B9,C2:C9)
=INDEX(C2:C9,MATCH(1,(A2:A9=F2)*(B2:B9=G2),0))
=SUMIFS(C2:C9,A2:A9,F2,B2:B9,G2)
Solve it in the sheet. Every answer is checked, with hints if you need them.
Task 1 of 2
In H2, return the price for the product in F2 in the size in G2.
Answer in H2.
Logic and text covers this in lesson 14, TEXTSPLIT.