How to use XLOOKUP on Filtered Data: A Comprehensive Guide
Excel’s XLOOKUP is a powerful function that simplifies searching for values in a dataset. However, when dealing with filtered data, standard lookup functions may not work as expected. This is where the FILTER function comes in, allowing you to refine your lookup by applying conditions dynamically.
By combining XLOOKUP with FILTER, you can create flexible and efficient lookups, ensuring that the results align with specific criteria. In this article, we will explore the syntax, examples, advantages, considerations, and alternative approaches for using XLOOKUP on filtered data.
Understanding XLOOKUP with FILTER
Basic Syntax
To use XLOOKUP on filtered data, apply the following formula:
=XLOOKUP(lookup_value, FILTER(lookup_array, condition), FILTER(return_array, condition))
- lookup_value: The value to search for.
- lookup_array: The range where the lookup is performed.
- return_array: The range where the corresponding value is retrieved.
- condition: The filtering condition applied to both lookup and return arrays.
By using FILTER within XLOOKUP, you ensure that the lookup happens only within the subset of data that meets your specified conditions.
You can also modify XLOOKUP by adding an if_not_found argument to handle missing values:
=XLOOKUP(lookup_value, FILTER(lookup_array, condition), FILTER(return_array, condition), "Value Not Found")
Examples of XLOOKUP on Filtered Data
1. Lookup with a Single Condition
Suppose we have the following dataset:
Name | Birth Year | Gender | Occupation |
---|---|---|---|
Alice | 1990 | Female | Engineer |
Bob | 1985 | Male | Teacher |
Carol | 1992 | Female | Doctor |
Dave | 1988 | Male | Lawyer |
If we want to find the Birth Year of a person based on their Gender, we can use:
=XLOOKUP(F2, FILTER(B2:B5, C2:C5=E2), FILTER(A2:A5, C2:C5=E2), "Not Found")
Where:
- F2 is the lookup value.
- E2 contains the gender we want to filter by.
- B2:B5 is the lookup range.
- A2:A5 is the return range.
- If no match is found, “Not Found” is returned.
This formula filters the dataset for the specified Gender before performing the lookup.
2. Lookup with Multiple Conditions
To refine our search further, we can use multiple conditions. Suppose we need to find a Birth Year for a person based on both Gender and Occupation:
=XLOOKUP(F2, FILTER(B2:B5, (C2:C5=E2)*(D2:D5=G2)), FILTER(A2:A5, (C2:C5=E2)*(D2:D5=G2)), "Not Found")
Where:
- G2 contains the person’s occupation.
- E2 specifies the gender.
- The FILTER function ensures that both conditions are met before performing the lookup.
Using multiple conditions helps narrow down the dataset for more precise searches.
Advantages of Using XLOOKUP with FILTER
1. Dynamic Filtering
- The FILTER function updates results automatically when data changes.
- Eliminates the need for manual sorting or filtering.
2. Flexibility with Multiple Conditions
- Enables lookups based on multiple criteria (e.g., Name, Gender, Occupation).
- Supports more complex searches compared to VLOOKUP or INDEX-MATCH.
3. Eliminates Helper Columns
- No need for extra columns to store pre-filtered results.
- Keeps the spreadsheet cleaner and more efficient.
4. Efficient and Scalable
- Works well with large datasets.
- Avoids performance issues related to array formulas in older Excel versions.
5. Works Well with Dynamic Arrays
- Helps create interactive dashboards.
- Can be used with Excel dynamic functions like SORT, UNIQUE, and SEQUENCE.
Considerations When Using XLOOKUP with FILTER
1. Ensure FILTER Returns a Valid Array
- If the FILTER function returns an empty array, XLOOKUP will produce an error.
- To prevent errors, include a fallback value like
"Not Found"
in the formula.
2. Both Filtered Arrays Must Have the Same Number of Rows
- The lookup array and return array must be filtered using the same condition to ensure matching row counts.
- Mismatched row counts can cause spilling errors.
3. Handling Errors Gracefully
Use IFERROR to prevent errors when no matches are found:
=IFERROR(XLOOKUP(F2, FILTER(B2:B5, C2:C5=E2), FILTER(A2:A5, C2:C5=E2)), "Not Found")
This ensures that the formula does not return an error if XLOOKUP fails to find a match.
4. XLOOKUP Works Only in Excel 365 and Excel 2019
- Older versions of Excel do not support XLOOKUP.
- Consider using INDEX-MATCH with FILTER as an alternative.
5. Performance Considerations
- Large datasets with FILTER and XLOOKUP may slow down calculations.
- Optimizing ranges and reducing unnecessary calculations can improve performance.
Alternative Approach: INDEX-MATCH with FILTER
If you are using an older version of Excel that does not support XLOOKUP, you can achieve similar results using INDEX-MATCH with FILTER.
For a single condition lookup, use:
=INDEX(A2:A5, MATCH(F2, FILTER(B2:B5, C2:C5=E2), 0))
For multiple conditions, use:
=INDEX(A2:A5, MATCH(F2, FILTER(B2:B5, (C2:C5=E2)*(D2:D5=G2)), 0))
While INDEX-MATCH is slightly more complex, it provides a workaround for older Excel versions.
Final Thoughts
Using XLOOKUP with FILTER allows for powerful, dynamic lookups in Excel. This combination provides greater flexibility, supports multiple conditions, and eliminates the need for helper columns. However, users must ensure that both lookup and return arrays have the same number of rows and handle potential errors effectively.
By mastering this technique, you can efficiently work with filtered data and create more advanced Excel formulas for data analysis, reporting, and automation.
Frequently Asked Questions
What is XLOOKUP and how does it work with FILTER?
XLOOKUP is an Excel function used to search for a value in one column and return a corresponding value from another column. When combined with the FILTER function, XLOOKUP can perform lookups only on filtered subsets of data, making searches more dynamic and efficient.
Can I use multiple conditions with XLOOKUP and FILTER?
Yes, you can apply multiple conditions in the FILTER function by using multiplication (*) for AND conditions and addition (+) for OR conditions. This allows you to refine your lookup results based on multiple criteria.
What happens if FILTER returns an empty array in XLOOKUP?
If the FILTER function returns an empty array, XLOOKUP will produce an error. To avoid this, you can specify a default value as the last argument in XLOOKUP or use the IFERROR function to handle errors gracefully.
Does XLOOKUP with FILTER work in all versions of Excel?
No, XLOOKUP and FILTER functions are available only in Excel 365 and Excel 2019. If you are using an older version, you can achieve similar results using INDEX-MATCH combined with FILTER.
How can I prevent errors when using XLOOKUP with FILTER?
To prevent errors, ensure that FILTER returns at least one result. You can also wrap the formula in IFERROR, for example: =IFERROR(XLOOKUP(...), "Not Found")
, to handle missing values.
Is XLOOKUP with FILTER better than VLOOKUP?
Yes, XLOOKUP with FILTER is more flexible and powerful than VLOOKUP. It allows searching in both directions, supports multiple conditions, and does not require sorted data, making it a more efficient alternative.

Vaishvi Desai is the founder of Excelsamurai and a passionate Excel enthusiast with years of experience in data analysis and spreadsheet management. With a mission to help others harness the power of Excel, Vaishvi shares her expertise through concise, easy-to-follow tutorials on shortcuts, formulas, Pivot Tables, and VBA.