To look up a value using multiple criteria across both rows and columns, combine XLOOKUP with Boolean logic (multiplication) to match all criteria in one formula, and use a second XLOOKUP (or MATCH) to return the correct column. The core pattern is: =XLOOKUP(1, (criteria_range1=criteria1)*(criteria_range2=criteria2), return_range) for row matching, and then wrap that inside another XLOOKUP to fetch the column header.
Why XLOOKUP Beats INDEX/MATCH for Multiple Criteria
Before XLOOKUP, Excel users had to combine INDEX and MATCH in an array formula, often requiring Ctrl+Shift+Enter in older versions. XLOOKUP handles arrays natively and is simpler to read. For a two‑way lookup (row and column), the older approach might look like =INDEX(A1:D10, MATCH(1, (A1:A10="North")*(B1:B10="Widget"),0), MATCH("Q2", A1:D1,0)). XLOOKUP replaces the row MATCH with a direct Boolean array and the column MATCH with a nested XLOOKUP, making the formula shorter and less error‑prone. XLOOKUP also has built‑in error handling (the if_not_found argument) and doesn’t require array entry.
The Basic XLOOKUP with Multiple Row Criteria
Suppose you have a table with columns: A (Region), B (Product), C (Salesperson), and D (Sales). You want the sales for Region “North” and Product “Widget”. With data in A2:D100, the formula is:
=XLOOKUP(1, (A2:A100="North")*(B2:B100="Widget"), D2:D100)
How it works: each comparison returns TRUE/FALSE. Multiplying them converts TRUE to 1 and FALSE to 0. The product is 1 only when both conditions are TRUE. XLOOKUP searches for the value 1 in that array and returns the corresponding value from the return range. If there are duplicate matches, XLOOKUP returns the first one by default. If no row matches, it returns #N/A unless you add the fourth argument, e.g., "Not found".
Adding Column Criteria: Two‑Way Lookup
Now suppose your table has multiple columns of data, such as Sales, Profit, and Units, and you want to match both a row (Region + Product) and a column header (e.g., “Profit”). The table might be: A (Region), B (Product), C (Sales), D (Profit), E (Units). To return the Profit for North/Widget, use:
=XLOOKUP("Profit", C1:E1, XLOOKUP(1, (A2:A100="North")*(B2:B100="Widget"), C2:E100))
Here the inner XLOOKUP returns the entire row (all three columns) for the matching row. The outer XLOOKUP then finds the column labeled “Profit” in the header row C1:E1 and returns that cell. This works because XLOOKUP can return an array (a row) when the return_range is a multi‑column range. If your table has the header row in row 1, adjust the ranges accordingly. For Excel for the web or Mac, the same formula works; just be careful with absolute references if you copy it.
Using XLOOKUP with AND/OR Logic
The multiplication operator (*) acts as AND – all conditions must be TRUE. If you need OR logic (any condition), use addition (+) instead. For example, to find the first row where Region is “North” OR “South”:
=XLOOKUP(1, ((A2:A100="North")+(A2:A100="South")), D2:D100)
But be careful: addition can produce values greater than 1 if both conditions are TRUE for the same row (which is impossible here, but could happen with overlapping criteria). To force a binary result, wrap each condition in N() or use -- (double unary). However, XLOOKUP will still find the first 1, so it’s usually fine. For complex logic, consider using the FILTER function instead, which is more flexible: =FILTER(D2:D100, (A2:A100="North")*(B2:B100="Widget")) returns all matches, not just the first.
Common Errors and How to Fix Them
- #VALUE! error: This often happens when the criteria ranges are not the same size. Ensure each range has the same number of rows.
- #N/A error: No match found. Use the
if_not_foundargument:=XLOOKUP(1, ..., "No match"). - Wrong column returned: Double‑check the header row range in the outer XLOOKUP – it must be a single row and align with the return range columns.
- Case sensitivity: XLOOKUP is case‑insensitive by default. If you need case‑sensitive matching, use
EXACTin the criteria:(EXACT(A2:A100,"north")). - Duplicate matches: XLOOKUP returns the first match. To get the last match, use the search_mode argument:
=XLOOKUP(1, ..., ..., ..., -1)searches from last to first.
Alternative: INDEX and MATCH with Array Formulas
If you’re using Excel 2019 or earlier, XLOOKUP is not available. The classic formula for multiple criteria is:
=INDEX(D2:D100, MATCH(1, (A2:A100="North")*(B2:B100="Widget"), 0))
In older Excel, you must enter this as an array formula with Ctrl+Shift+Enter. For a two‑way lookup, combine with MATCH for the column:
=INDEX(C2:E100, MATCH(1, (A2:A100="North")*(B2:B100="Widget"),0), MATCH("Profit", C1:E1,0))
This works but is harder to read. In Excel 365, you can also use FILTER to return all matching rows, then use INDEX to pick a specific column: =INDEX(FILTER(C2:E100, (A2:A100="North")*(B2:B100="Widget")), 1, MATCH("Profit", C1:E1,0)). This returns the first matching row’s Profit.
Frequently Asked Questions
Can XLOOKUP handle three or more criteria?
Yes, simply multiply more Boolean arrays: =XLOOKUP(1, (A2:A100="North")*(B2:B100="Widget")*(C2:C100="John"), D2:D100). There’s no practical limit, but the formula gets long. For readability, consider using LET to define criteria ranges as variables, e.g., =LET(rngA,A2:A100, rngB,B2:B100, XLOOKUP(1,(rngA="North")*(rngB="Widget"),D2:D100)).
Why does my XLOOKUP return #VALUE! when I use multiple criteria?
Most often the ranges in the Boolean multiplication are not the same size. For example, if you use A2:A100 and B2:B101, the arrays are different lengths and Excel cannot multiply them. Check that every criteria range has exactly the same number of rows. Also, ensure you’re not mixing a row range with a column range unintentionally.
How do I return multiple matching rows with XLOOKUP?
XLOOKUP only returns the first match by default. To get all matches, use FILTER instead: =FILTER(D2:D100, (A2:A100="North")*(B2:B100="Widget")). If you need to return multiple columns, use =FILTER(A2:E100, ...).
Can I use XLOOKUP with wildcards for partial matches?
Yes, XLOOKUP supports wildcards: ? (any single character) and * (any sequence). For example, =XLOOKUP("Wi*", B2:B100, D2:D100) matches “Widget” and “Wire”. However, when using wildcards with multiple criteria, the wildcard applies to the lookup value, not the criteria range. For partial matches in criteria, you’d need to use functions like ISNUMBER(SEARCH(...)) inside the Boolean logic, which is more complex.
Does XLOOKUP work in Google Sheets?
XLOOKUP is not available in Google Sheets. Instead, use INDEX and MATCH or the FILTER function. For example, to return the first match with multiple criteria: =INDEX(D2:D100, MATCH(1, (A2:A100="North")*(B2:B100="Widget"),0)) – in Google Sheets, this works as an array formula without Ctrl+Shift+Enter (it’s automatic).
What if my criteria are in cells, not hardcoded?
Simply replace the quoted text with cell references. For instance, if E1 contains “North” and F1 contains “Widget”, use =XLOOKUP(1, (A2:A100=E1)*(B2:B100=F1), D2:D100). This makes the formula dynamic and easier to update.
Related
- Traffic Signs in Kansas: Rules, Colors, and Meanings
- Federal Reserve Balance Sheet Explained
- How to Split a String in PySpark (with Examples)
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Data Validation Custom Formula Examples That WorkExcel custom data validation lets you accept an entry only when a formula returns TRUE. In Microsoft 365…
- SUMIF Excel Criteria: Syntax, Examples, and Common FixesIn Excel, SUMIF criteria tell the function which cells to check before adding matching values. For example, with…
- Excel Unique Exclude Duplicates: 5 WaysTo exclude duplicates and list only unique values in Excel, use the UNIQUE function: =UNIQUE(range). For example, =UNIQUE(A2:A20)…
- How to Find Repeated Names in Excel with COUNTIF FormulaTo find repeated names in Excel, put names in A2:A100, then enter =COUNTIF($A$2:$A$100,A2) in B2 and fill it…
- PV of Annuity Formula in Excel: Examples and TimingWith the annual interest rate in A2, the number of annual payments in B2, and each end-of-year payment…
- Excel Test If Two Cells Are Equal: Formulas and FixesTo test whether two cells are equal in Excel, enter =A1=B1 in another cell, replacing A1 and B1…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.