XLOOKUP with Two Criteria: How to Match on Two Values

Formulas & functions · Updated November 22, 2026

To look up a value based on two criteria in Excel, use the XLOOKUP function with a concatenated lookup value and a concatenated lookup array, like this: =XLOOKUP(A2&B2, C:C&D:D, E:E). This joins the two criteria into a single lookup key and matches it against the joined lookup columns, returning the corresponding value from the result column.

Why You Need Two-Value Lookups

In many real-world tables, a single column isn’t unique. For example, an order list might have multiple rows for the same product on the same date, or a price list might have the same item code in different regions. When your key is only unique when you combine two columns—like Product ID and Region—a standard VLOOKUP or XLOOKUP on one column will return the first match, which is often wrong. Combining the two criteria into one lookup key solves this by making the match unique.

How the Concatenation Method Works

The core trick is using the ampersand (&) to join text. In Excel, A2&B2 creates a single text string like “ABC-123” if A2 is “ABC” and B2 is 123. The lookup array C:C&D:D does the same for every row in those columns. Excel then finds the row where the joined lookup array equals the joined lookup value.

Example layout: with product codes in A2:A10, regions in B2:B10, and prices in C2:C10, and with the criteria you want to search for in E2 (product) and F2 (region), the formula is:

=XLOOKUP(E2&F2, A2:A10&B2:B10, C2:C10)

If E2 is “P-100” and F2 is “West”, the formula looks for “P-100West” in the array of joined codes and regions, and returns the matching price. This works in Excel 2021 and Microsoft 365. In earlier versions, you’d use an array formula with INDEX and MATCH, but XLOOKUP is simpler.

Handling Numbers and Text in the Join

A common pitfall: if one of your criteria is a number (like a year or ID), joining it with text may cause mismatches if the number is stored as text in one place and as a number in another. To avoid this, use the TEXT function to normalize the format. For example:

=XLOOKUP(E2&TEXT(F2,"0"), A2:A10&TEXT(B2:B10,"0"), C2:C10)

This forces both the lookup value and the lookup array to treat the numbers as plain integers, preventing errors where “123” and 123 don’t match. If your criteria include dates, use TEXT with a format like “yyyy-mm-dd” to make them consistent.

Using XLOOKUP with Multiple Columns Without Concatenation

If you have Excel 365, you can also use the XLOOKUP function with a boolean expression to check two separate columns. This method doesn’t require concatenation and can be more readable:

=XLOOKUP(1, (A2:A10=E2)*(B2:B10=F2), C2:C10)

Here, the (A2:A10=E2) returns an array of TRUE/FALSE, and multiplying by (B2:B10=F2) converts them to 1/0 and multiplies, giving 1 only when both conditions are TRUE. XLOOKUP then finds the first 1 in that array and returns the corresponding price. This is a powerful alternative that avoids text-format issues, but it’s slightly more complex to understand.

Choosing Between Concatenation and Boolean Logic

  • Concatenation is better when your criteria are text or when you want a simple, short formula. It’s also faster on large datasets because it creates a single array to search.
  • Boolean multiplication is more robust with mixed data types (numbers, dates) and is easier to debug because you can see the conditions separately.
  • If your table has duplicate combinations, both methods return the first match. To get the last match, use XLOOKUP with the search mode argument set to -1 (search from last to first).

Common Problems and How to Fix Them

One frequent issue is getting #N/A even when you know the data exists. This usually happens because of invisible characters (like spaces) or different data types. To fix, use the TRIM function to remove extra spaces: =XLOOKUP(TRIM(E2)&TRIM(F2), TRIM(A2:A10)&TRIM(B2:B10), C2:C10). Another issue is when your lookup array has a different number of rows than your result column—make sure all ranges are the same size. Also, if you’re using the boolean method, remember to enter it as a normal formula (no Ctrl+Shift+Enter needed in Excel 365).

Alternatives: INDEX/MATCH and FILTER

If you’re using an older Excel version without XLOOKUP, you can use INDEX and MATCH with concatenation:

=INDEX(C2:C10, MATCH(E2&F2, A2:A10&B2:B10, 0))

This is an array formula, so in Excel 2019 and earlier you must press Ctrl+Shift+Enter. In Excel 365, it works normally. Another alternative is the FILTER function, which returns all matching values, not just the first:

=FILTER(C2:C10, (A2:A10=E2)*(B2:B10=F2))

This is useful when you expect multiple matches and want to see them all. It requires Microsoft 365 or Excel 2021.

Frequently Asked Questions

Can I use XLOOKUP with two criteria without concatenating the columns?

Yes, you can use the boolean method: =XLOOKUP(1, (range1=crit1)*(range2=crit2), result_range). This avoids text-format issues and is often easier to read, though it may be slightly slower on very large datasets because it creates two arrays.

Why does my XLOOKUP return #N/A even though the values exist?

The most common causes are extra spaces in the data, number stored as text, or mismatched row counts. Use TRIM to remove spaces, use TEXT to normalize numbers, and verify that all ranges have the same number of rows.

How do I get the last match instead of the first when using two criteria?

Add the search mode argument to XLOOKUP: =XLOOKUP(E2&F2, A2:A10&B2:B10, C2:C10, , , -1). The -1 tells Excel to search from the last row to the first, returning the last matching value.

Does this work in Google Sheets?

Google Sheets has XLOOKUP as of 2022, so the same concatenation formula works. For older versions, use FILTER or INDEX/MATCH. The syntax is identical for concatenation, but note that Google Sheets may handle array formulas differently—you might need to wrap them in ARRAYFORMULA in some cases.

Can I use two criteria with VLOOKUP?

Yes, but you must add a helper column that concatenates the two criteria, then use that column as the lookup column. For example, add a column D with =A2&B2, then use =VLOOKUP(E2&F2, D:C, 3, FALSE). This is less elegant than XLOOKUP but works in all versions.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.