Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Google Sheets XLOOKUP With Multiple Criteria

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Google Sheets has a function called XLOOKUP, and it can match on more than one condition at once, but not by handing it several criteria the way you might hope. The working method is to join the criteria into a single search key. You either concatenate the columns you want to match (=A2:A100&"|"&B2:B100) or, more robustly, build a single array inside XLOOKUP with the ampersand operator and set the match mode to wildcard. The pattern looks like this: =XLOOKUP(F2&"|"&G2, A2:A100&"|"&B2:B100, C2:C100), where F2 and G2 hold the two values you are searching for and C holds the result column. That one formula handles two criteria, and you can add a third or fourth the same way. The rest of this guide covers setup, the exact syntax, a wildcard variant, and the errors that trip most people up.

What You'll Need

  • A Google account and access to Google Sheets in a browser (desktop is easiest; the mobile app supports XLOOKUP but entering long array formulas on a phone is painful).
  • A table where the columns you want to match are separate and consistent, with no merged cells inside the data range.
  • A place to put the search values and the formula result, ideally on the same sheet or a clearly named tab.
  • Basic familiarity with cell references (A2, B2:B100) and with wrapping text in quotes.

Step-by-Step

  1. Lay out your data cleanly. Put each criterion in its own column with a header row. For example, column A holds a product code, column B holds a region, and column C holds the price you want to return. Avoid blank rows in the middle of the range and avoid merged cells, because both break array matching in confusing ways.
  2. Place your search values somewhere visible. Say you type the product code in F2 and the region in G2. Keep them on the same sheet as the formula if you can, so you do not have to chase cross-sheet references while debugging.
  3. Write the basic two-criteria formula. In an empty cell, enter =XLOOKUP(F2&"|"&G2, A2:A100&"|"&B2:B100, C2:C100). The first argument joins your two search values with a separator. The second argument joins the two data columns with the same separator. The third argument is the column you want back. Press Enter and the matching value appears.
  4. Understand why the separator matters. Without it, "AB" plus "C" and "A" plus "BC" both collapse to "ABC" and you get false matches. A pipe character, a tilde, or a rare string like "@@" makes accidental collisions far less likely. Pick one and use exactly the same one on both sides of the lookup.
  5. Add a third criterion if needed. Extend both sides equally: =XLOOKUP(F2&"|"&G2&"|"&H2, A2:A100&"|"&B2:B100&"|"&D2:D100, C2:C100). The number of joined items must match on both sides, in the same order, or the lookup silently fails to find anything.
  6. Wrap the formula in IFNA for clean output. Something like =IFNA(XLOOKUP(...), "Not found") stops ugly #N/A errors from spreading across your sheet when a combination genuinely does not exist.
  7. Use a wildcard approach for partial matches. If you want to match on a pattern rather than an exact string, you can join with a wildcard character and set the match mode argument to 2. The syntax is =XLOOKUP(F2&"*"&G2, A2:A100&"*"&B2:B100, C2:C100) with match mode 2 and search mode 1. This is more fragile than exact matching, so verify a few results by eye before trusting the whole column.
  8. Copy the formula down. Drag the fill handle or copy and paste. Relative references should shift so that each row looks up its own criteria. If you want to lock the data ranges while the criteria move, use dollar signs on the data side: $A$2:$A$100.
  9. Test with known values. Pick two or three rows where you already know the answer, enter their criteria, and confirm the formula returns the right result. This catches separator mismatches and off-by-one range errors before they spread.

Common Mistakes

Mismatched separators. The most common failure is using a pipe on one side and a hyphen on the other, or forgetting the separator entirely on one side. The formula returns #N/A even though the data is clearly there. Check both sides character by character.

Unequal range lengths. If the first array covers rows 2 to 100 and the second covers rows 2 to 90, Google Sheets returns an error or gives inconsistent results. Both joined ranges must be the same size and start on the same row.

Extra spaces. A trailing space in the source data or in your search value breaks an exact match invisibly. Using TRIM around your search value, or cleaning the data first, saves a lot of head-scratching.

Numbers stored as text. A product code typed as text in one column and stored as a number in another will not match. The formats must align, so check with a quick ISTEXT test if results look odd.

Forgetting the result column is relative. When you copy down, the return column shifts too, which is usually what you want. If it is not, anchor it.

Tips

  • Build the joined-key helper as a separate hidden column in your data table (for example, a column that concatenates the two criteria) and point XLOOKUP at that column. It is easier to audit than a long inline array and makes the formula readable for anyone else opening the sheet.
  • Name your ranges (Data > Named ranges) so the formula reads =XLOOKUP(F2&"|"&G2, ProductKeys, Prices) instead of a wall of cell references.
  • Keep the separator unusual. A pipe or a tilde is far safer than a space or a comma, which appear naturally inside names and addresses.
  • If you only need to check existence rather than return a value, the same joined-key technique works with COUNTIFS or with XLOOKUP against a helper column, whichever you find clearer.
  • Test your formula on a copy of the sheet before applying it to a large dataset, so a mistake does not cascade through hundreds of rows.

Troubleshooting

It returns #N/A. Work through the causes in order: confirm the separator matches on both sides, confirm both joined arrays are the same length, check for trailing spaces and for numbers stored as text, and confirm the search value actually exists as an exact combination. Temporarily simplify to a single-criterion XLOOKUP to prove the result column and ranges are right, then add the second criterion back.

It returns the wrong row. This usually means the ranges are offset by a row or the criteria order is swapped. Verify that the first item joined on the search side corresponds to the first column joined on the data side.

It returns #VALUE! or #REF!. A range reference is broken, often after a row or column was deleted. Re-enter the ranges, or switch to named ranges so deletions are handled more gracefully.

The wildcard version gives strange results. Wildcard matching is broader than exact matching, so it can pick up unrelated rows. If you need precision, go back to the split value separator pattern instead of wildcards. Also confirm the match mode argument is set to 2, since the default exact match will not treat the asterisk as a wildcard.

The formula works on one row but not after copying. Check whether the data ranges shifted when they should have stayed fixed. Add dollar signs to the data ranges, then copy again.

Frequently Asked Questions

Can XLOOKUP match two criteria directly?

Not with separate arguments. XLOOKUP takes one lookup value and one lookup range. You achieve multiple criteria by joining the values and the columns into single strings with the ampersand operator, then matching those strings.

Do I need a helper column?

No. You can join the columns inside the formula as an array. A helper column is optional and makes the formula easier to read and audit, but it is not required.

What separator should I use?

Any string that will not appear inside your data. A pipe, a tilde, or a double-at sign are common choices. Whatever you pick, use the identical separator on both the search side and the data side.

Can I use more than two criteria?

Yes. Add another &"|"& and another column to both sides for each criterion. The order and count must match exactly on both sides.

Why does my formula return #N/A when the data is clearly there?

Almost always a separator mismatch, a trailing space, or a number stored as text on one side. Clean the values and recheck both sides character by character.

Does XLOOKUP work in the Google Sheets mobile app?

Yes, the function is available, but entering long array formulas on a phone is fiddly. Building the formula on desktop and opening the sheet on mobile afterward is far easier.