To return all matches with XLOOKUP instead of just the first one, you must combine it with the FILTER function: =FILTER(return_range, lookup_range=lookup_value). XLOOKUP alone is designed to return a single match (the first by default, or the last with the search mode set to -1), so when you need every matching row, FILTER is the correct tool. This article explains why XLOOKUP behaves this way, how to build multi-match formulas, and what to do when you need the results in a single cell.
Why XLOOKUP Returns Only One Match
XLOOKUP, introduced in Excel 2021 and Microsoft 365, was built as a modern replacement for VLOOKUP and HLOOKUP. Its core job is to find one value in a lookup array and return a corresponding value from a return array. By default, it scans from top to bottom and stops at the first exact match. You can change the search mode to -1 to find the last match, but there is no built-in option to return multiple matches.
This single-match behavior is intentional. It keeps the function fast and predictable for everyday lookups like finding a customer’s address or a product’s price. When your data contains duplicate lookup values—say, multiple orders for the same customer—you need a different approach. Excel’s FILTER function, added in the same 2021 update, is the natural companion because it returns an array of all rows that meet a condition.
The FILTER Formula for All Matches
The simplest way to get every match is:
=FILTER(C2:C20, A2:A20=E2)
Assumes: names in A2:A20, amounts in C2:C20, and the lookup name in E2. This returns a vertical list of all amounts where the name in column A equals E2. If there are three matching rows, the formula spills three results down the column. If no match exists, FILTER returns a #CALC! error by default.
To handle no-match gracefully, add the optional if_empty argument:
=FILTER(C2:C20, A2:A20=E2, "No matches")
This works in Excel 2021, Excel 2024, and Microsoft 365. On Excel for the web, FILTER is also available. On Mac, the formula is identical—no special syntax changes.
Returning Multiple Columns for Each Match
Often you want the entire row for each match, not just one column. FILTER makes this easy: just use a multi-column return range.
=FILTER(A2:D20, A2:A20=E2)
Assumes: data in A2:D20, with the lookup name in column A and the target in E2. This returns all columns (A through D) for every row where column A matches E2. The results spill both down and across. If you only need specific columns, you can wrap FILTER inside CHOOSECOLS (available in Microsoft 365 and Excel 2024):
=CHOOSECOLS(FILTER(A2:D20, A2:A20=E2), 1, 3, 4)
This returns columns 1, 3, and 4 of the filtered rows.
Combining Multiple Conditions
Sometimes you need to match on more than one criterion, like a customer name and a product category. FILTER supports this with the multiplication operator (*) for AND logic:
=FILTER(C2:C20, (A2:A20=E2)*(B2:B20=F2))
Assumes: names in A2:A20, categories in B2:B20, amounts in C2:C20, lookup name in E2, and category in F2. The parentheses around each condition are required. This returns amounts only where both conditions are true. For OR logic, use the plus operator (+).
Putting All Matches into a Single Cell
If you want the matches listed in one cell separated by commas or line breaks, combine FILTER with TEXTJOIN. TEXTJOIN is available in Excel 2019 and later.
=TEXTJOIN(", ", TRUE, FILTER(C2:C20, A2:A20=E2))
Assumes: names in A2:A20, amounts in C2:C20, lookup name in E2. This joins all matching amounts with a comma and space. The second argument, TRUE, ignores empty cells. For line breaks, use CHAR(10) as the delimiter and ensure Wrap Text is enabled on the cell.
When You Still Need XLOOKUP
FILTER is the go-to for multiple matches, but XLOOKUP remains useful when you need only the first or last match and want to avoid array formulas. For example, to get the first matching amount:
=XLOOKUP(E2, A2:A20, C2:C20)
To get the last matching amount, add the search mode argument:
=XLOOKUP(E2, A2:A20, C2:C20, "Not found", 0, -1)
The fifth argument (0) means exact match, and the sixth (-1) means search from last to first. This is handy for pulling the most recent transaction from a log sorted oldest to newest. If your data is not sorted, you can sort it with SORT or use XLOOKUP’s binary search modes, but exact match is safer.
Common Problems and Fixes
- #CALC! error: FILTER returns this when no rows match. Add the third argument (if_empty) to display a message instead.
- #SPILL! error: This happens when the formula’s results would overwrite existing cells. Clear the cells below and to the right of the formula, or move the formula to a location with enough empty space.
- Results not updating: If you’re using Excel 2019 or earlier, FILTER doesn’t exist. Use an array formula with IF and SMALL, or upgrade to Microsoft 365.
- Trailing spaces or extra characters: Use TRIM and CLEAN on your lookup values and data ranges to avoid mismatches.
- Case sensitivity: FILTER and XLOOKUP are case-insensitive by default. If you need case-sensitive matching, use EXACT inside a condition:
FILTER(C2:C20, EXACT(A2:A20, E2)).
Frequently Asked Questions
Can XLOOKUP return multiple matches natively?
No. XLOOKUP only returns one match. To get multiple matches, you must use FILTER or a combination of INDEX, SMALL, and IF (for older Excel versions). FILTER is the modern, simpler solution.
How do I get the second or third match with XLOOKUP?
XLOOKUP cannot return the nth match directly. You can use FILTER to get all matches and then use INDEX to pick a specific one: =INDEX(FILTER(C2:C20, A2:A20=E2), 2) returns the second match. Alternatively, use the SMALL function with IF in older versions.
What is the difference between FILTER and XLOOKUP for multiple matches?
FILTER returns an array of all rows that meet your criteria, spilling them down and across. XLOOKUP returns a single value. Use FILTER when you need a list; use XLOOKUP when you only need the first or last match.
Does FILTER work in Excel 2019?
No. FILTER was introduced in Excel 2021 and Microsoft 365. In Excel 2019, you can use an array formula with INDEX, SMALL, IF, and ROW, but it’s more complex. Consider upgrading to Microsoft 365 for access to FILTER, SORT, UNIQUE, and other dynamic array functions.
How do I return multiple matches in Google Sheets?
Google Sheets also has a FILTER function that works similarly: =FILTER(C2:C20, A2:A20=E2). The main difference is that Google Sheets uses semicolons as argument separators in some locales, but the function name and logic are the same. XLOOKUP is not available in Google Sheets; use VLOOKUP or INDEX/MATCH instead.
Can I use FILTER with a wildcard like * or ?
FILTER does not support wildcards directly. If you need partial matching, use ISNUMBER(SEARCH(“text”, range)) as the condition. For example, =FILTER(C2:C20, ISNUMBER(SEARCH(E2, A2:A20))) returns all rows where column A contains the text in E2.
Related
- Select All Windows Explorer: Steps & Tips
- City 8 Codes for Traffic Signals Explained
- Federal Reserve Balance Sheet Explained Simply
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- C String Functions: How They Work and When to Use ThemC string functions are standard library routines declared in <string.h> for measuring, copying, comparing, joining, and searching strings.…
- INDIRECT Excel Formula for a Different Sheet: ExamplesIf cell A1 contains a worksheet name and you want the value in B2 on that sheet, use…
- Excel Filter Duplicates Across Multiple ColumnsYes. In Excel for Microsoft 365 on Windows, add a helper column that counts how often each row’s…
- JavaScript String match(): How It Works and When to Use ItJavaScript’s String.prototype.match() method searches a string using a regular expression and returns information about the match, or null…
- Weekday Excel Shortcut: Formulas and Fast Ways to Get ItExcel has no dedicated keyboard shortcut that turns a selected date into its weekday. For a date in…
- IFERROR with AVERAGE in Excel: Formulas and ExamplesTo use IFERROR with AVERAGE in Excel, wrap the average calculation in IFERROR: with the values to average…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.