XLOOKUP is great at finding a value based on one condition. But real data rarely works that way. You often need the sales figure for a specific region, product and month at the same time. In this tutorial you will learn two reliable ways to use XLOOKUP with multiple criteria, without adding a helper column.
=XLOOKUP(1, (range1=value1)*(range2=value2), return_range, "Not found")The example data
We will use a small sales table. Columns A to D hold the data, and cells G2:G4 hold the three things we want to match: region, product and month.
| A: Region | B: Product | C: Month | D: Sales | |
|---|---|---|---|---|
| 2 | East | Laptop | Jan | 12,500 |
| 3 | West | Laptop | Jan | 9,800 |
| 4 | East | Monitor | Jan | 4,200 |
| 5 | West | Monitor | Jan | 3,900 |
| 6 | East | Laptop | Feb | 13,100 |
| 7 | West | Laptop | Feb | 10,450 |
| 8 | East | Monitor | Feb | 4,600 |
| 9 | West | Monitor | Feb | 4,150 |
Method 1: Multiply the conditions (recommended)
Enter this formula in G6:
=XLOOKUP(1,(A2:A9=G2)*(B2:B9=G3)*(C2:C9=G4),D2:D9,"Not found")
With West, Laptop and Feb in G2:G4, the result is 10,450, the value in row 7.
How it works
(A2:A9=G2)compares every region with "West" and returns a list of TRUE/FALSE values.- The same happens for product and month.
- Multiplying the three lists turns TRUE into 1 and FALSE into 0. A row only gets a 1 if all conditions are true; otherwise it gets 0.
- XLOOKUP then searches that list for the number
1and returns the matching value from D2:D9.
The multiplication sign works like AND. Do not use the AND() function here: it collapses everything into a single TRUE or FALSE instead of checking row by row.
XLOOKUP returns the first match
If more than one row meets your criteria, XLOOKUP returns the first one it finds. For example, with only two criteria (West + Laptop), the formula returns 9,800 from January, because row 3 comes before row 7. To get the last match instead, set the sixth argument (search mode) to -1:
=XLOOKUP(1,(A2:A9=G2)*(B2:B9=G3),D2:D9,"Not found",0,-1)
Method 2: Join the criteria together
The second approach combines the criteria into one text string and looks it up in a combined version of the columns:
=XLOOKUP(G2&"|"&G3&"|"&G4,A2:A9&"|"&B2:B9&"|"&C2:C9,D2:D9,"Not found")
This also returns 10,450. The | separator is important. Without it, different combinations can produce the same text (for example "AB" + "C" and "A" + "BC" both become "ABC") and return the wrong row.
Method 1 is usually the better choice because it also works with numbers, dates and comparisons such as (D2:D9>5000). Method 2 is handy when you find it easier to read.
What if no row matches?
The fourth argument, "Not found", is what XLOOKUP shows when there is no match. If you change G2 to "North" (a region that does not exist in the table), the formula returns Not found instead of an #N/A error.
Older Excel versions: INDEX and MATCH
XLOOKUP is available in Excel for Microsoft 365, Excel 2021, Excel 2024 and Excel for the web. In Excel 2019 and earlier, use INDEX with MATCH and the same multiplication trick:
=INDEX(D2:D9,MATCH(1,(A2:A9=G2)*(B2:B9=G3)*(C2:C9=G4),0))
In those older versions, confirm the formula with Ctrl + Shift + Enter so Excel treats it as an array formula.
Google Sheets
Google Sheets also has XLOOKUP, and Method 1 uses the same structure. If you want every matching row rather than just the first, use FILTER instead:
=FILTER(D2:D9,(A2:A9=G2)*(B2:B9=G3)*(C2:C9=G4))
Common mistakes
- Ranges of different sizes. All ranges (A2:A9, B2:B9, C2:C9, D2:D9) must have the same number of rows, or you will get a
#VALUE!error. - Hidden spaces. "West " with a trailing space is not the same as "West". Clean your data with TRIM if matches fail unexpectedly.
- Numbers stored as text. A month number typed as text ("2") will not match the number 2.
- Looking up TRUE instead of 1. After multiplying, the list contains 1s and 0s, so the lookup value must be
1.
Frequently asked questions
Can XLOOKUP return more than one result?
No. XLOOKUP returns one match per formula (the first or the last). Use FILTER to return all matching rows.
Is XLOOKUP case-sensitive?
No. To make one condition case-sensitive, replace it with EXACT, for example EXACT(A2:A9,G2)*(B2:B9=G3).
How many criteria can I use?
As many as you need. Just add another *(range=value) block for each extra condition.
Summary
To use XLOOKUP with multiple criteria, multiply each condition together and look up the number 1. It is fast, needs no helper column, and works with any number of conditions. Next, learn how to fix #N/A errors when a lookup does not find what you expect.
Komentar
Posting Komentar