ElyxAI

XLOOKUP Function: The Modern Solution to Excel Lookup Challenges

Intermediate
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

The XLOOKUP function represents a significant advancement in Excel's lookup capabilities, designed to address the limitations of older functions like VLOOKUP and INDEX/MATCH. Introduced in Excel 365 and Excel 2021, XLOOKUP provides a more intuitive, flexible, and powerful approach to searching for values within data ranges. This function allows you to search in any direction—left or right—eliminating the need for complex workarounds that plagued previous lookup methods. XLOOKUP is particularly valuable for data analysts, business intelligence professionals, and anyone working with large datasets who needs reliable, error-tolerant lookup operations. The function's ability to handle missing values gracefully, search in multiple directions, and integrate seamlessly with modern Excel workflows makes it an essential tool for contemporary spreadsheet management. Whether you're consolidating data from multiple sources, creating dynamic dashboards, or building complex reporting systems, understanding XLOOKUP will significantly enhance your Excel proficiency and productivity.

Syntax & Parameters

The XLOOKUP formula follows this structure: =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode]). Let's examine each parameter in detail: **lookup_value** (required) is the specific value you're searching for within your dataset. This can be a cell reference, text string, number, or logical value. **lookup_array** (required) is the range or array where XLOOKUP will search for your lookup value. Unlike VLOOKUP, this array can be positioned anywhere relative to your return array—left, right, above, or below. **return_array** (required) specifies which range contains the values you want to retrieve once a match is found. This array must have the same dimensions as your lookup array. **if_not_found** (optional) allows you to specify a custom message or value if no match is found, replacing the default #N/A error. This parameter is crucial for creating user-friendly spreadsheets. **match_mode** (optional) controls how XLOOKUP matches values: 0 for exact match (default), -1 for exact match or next smallest value, 1 for exact match or next largest value, and 2 for wildcard matching. **search_mode** (optional) determines search direction: 1 searches first-to-last (default), -1 searches last-to-first, 2 performs binary search ascending, and 3 performs binary search descending. Understanding these parameters enables you to create sophisticated lookup operations tailored to your specific data structure and requirements.

lookup_value
Value to search for
lookup_array
Range to search
return_array
Range to return
if_not_found
Value if not found
Optional
match_mode
Match mode
Optional
search_mode
Search mode
Optional

Practical Examples

Employee Salary Lookup by Employee ID

=XLOOKUP(E2, A:A, D:D, "Employee not found", 0)

This formula searches for the Employee ID in cell E2 within column A (Employee ID column). When found, it returns the corresponding value from column D (Salary column). If the Employee ID doesn't exist, it displays "Employee not found" instead of an error, making the spreadsheet more user-friendly and professional.

Product Price Lookup with Wildcard Matching

=XLOOKUP("*"&F2&"*", B:B, C:C, "Price not available", 2)

Using match_mode 2 (wildcard matching), this formula searches for any product name containing the text in cell F2. The asterisks (*) act as wildcards matching any characters before and after the search term. This flexibility is invaluable for real-world scenarios where users may not know exact product names or codes.

Reverse Lookup: Finding Customer Names from Transaction IDs

=XLOOKUP(G2, C:C, A:A, "Unknown customer", 0, -1)

This formula demonstrates XLOOKUP's ability to search from last-to-first using search_mode -1. The lookup array (Column C) is to the right of the return array (Column A), a scenario where traditional VLOOKUP would fail. XLOOKUP handles this effortlessly, making it superior for complex data layouts.

Key Takeaways

  • XLOOKUP is the modern replacement for VLOOKUP, offering bidirectional search, better error handling, and more intuitive syntax—available in Excel 365 and Excel 2021.
  • The optional if_not_found parameter eliminates #N/A errors and enables custom error messages, creating more professional and user-friendly spreadsheets.
  • XLOOKUP supports wildcard matching and approximate matching through match_mode parameter, enabling sophisticated data retrieval beyond simple exact matches.
  • Understanding search_mode allows you to control search direction (first-to-last vs. last-to-first) and implement binary search for performance optimization with large sorted datasets.
  • For Excel versions prior to 2021, INDEX/MATCH combinations provide similar flexibility, though with more complex syntax and slightly different functionality.

Pro Tips

Use the if_not_found parameter strategically to create self-documenting spreadsheets. Instead of cryptic #N/A errors, use descriptive messages like "Sales Rep not found" or "Product discontinued" to make your data more interpretable.

Impact : Significantly improves spreadsheet usability and reduces confusion for other users; makes debugging easier and creates professional-quality reports.

Leverage search_mode -1 to find the most recent entry when your data contains timestamps or sequential records. This is particularly useful for inventory tracking, customer history, or version control scenarios.

Impact : Enables sophisticated data analysis without additional sorting or helper columns; saves time and reduces formula complexity in time-series analyses.

Test wildcard matching (match_mode 2) with partial product names or partial text searches to create flexible lookup systems that tolerate minor variations in user input, such as different cases or abbreviated names.

Impact : Creates more forgiving user interfaces that handle real-world data inconsistencies; reduces lookup failures due to minor data entry variations.

When working with large datasets, specify exact range references instead of entire columns (e.g., A2:A10000 instead of A:A) to improve calculation performance and reduce memory usage, especially in workbooks with many formulas.

Impact : Noticeably improves spreadsheet responsiveness; reduces file size and prevents slowdowns in complex workbooks with thousands of formulas.

Useful Combinations

XLOOKUP with IFERROR for Error Handling

=IFERROR(XLOOKUP(E2, A:A, D:D, "Not found"), "Error occurred")

Combining XLOOKUP with IFERROR provides double-layer error handling. While XLOOKUP's if_not_found parameter handles missing values, IFERROR catches any other potential errors (like #VALUE!), ensuring your spreadsheet remains robust and user-friendly in all scenarios.

XLOOKUP with SUM for Aggregated Returns

=SUM(XLOOKUP(G2, C:C, D:D, 0, 0, 1))

This combination allows you to sum multiple matching values. XLOOKUP finds all instances matching your criteria, and SUM aggregates them. This is powerful for sales analysis where you need total sales by region or product category.

XLOOKUP with CONCATENATE for Composite Keys

=XLOOKUP(CONCATENATE(E2,"-",F2), CONCATENATE(A:A,"-",B:B), D:D, "No match")

For multi-field lookups, combine XLOOKUP with CONCATENATE to create composite lookup keys. This enables searching based on multiple criteria combined into a single lookup value, essential for complex database scenarios with non-unique individual fields.

Common Errors

#NAME?

Cause: This error occurs when using XLOOKUP in Excel versions that don't support it (Excel 2019 or earlier). The function is only available in Excel 365 and Excel 2021.

Solution: Upgrade to Excel 365 or Excel 2021, or use alternative functions like VLOOKUP, INDEX/MATCH, or XLOOKUP's predecessor functions. Check your Excel version by clicking File > Account > About Excel.

#N/A

Cause: This error appears when XLOOKUP cannot find the lookup value in the lookup array and no if_not_found parameter is specified. This is the default behavior when no match exists.

Solution: Add the optional if_not_found parameter to provide a custom message: =XLOOKUP(lookup_value, lookup_array, return_array, "Not found"). Alternatively, verify that your lookup value matches the data exactly, checking for extra spaces, different cases, or formatting issues.

#VALUE!

Cause: This error typically occurs when the lookup_array and return_array have different dimensions or when parameters are incorrectly formatted. Array size mismatches prevent XLOOKUP from functioning properly.

Solution: Ensure both arrays have identical dimensions (same number of rows or columns). Verify that all parameters use correct syntax and data types. Use the ROWS() and COLUMNS() functions to check array dimensions: =ROWS(lookup_array) should equal =ROWS(return_array).

Troubleshooting Checklist

  • 1.Verify you're using Excel 365 or Excel 2021—XLOOKUP is not available in earlier versions. Check Help > About Microsoft Excel to confirm your version.
  • 2.Confirm that lookup_array and return_array have identical dimensions (same number of rows and columns). Use ROWS() and COLUMNS() functions to verify sizes match.
  • 3.Check for extra spaces or formatting differences in your lookup_value compared to values in lookup_array. Use TRIM() function to remove leading/trailing spaces: =XLOOKUP(TRIM(E2), TRIM(A:A), D:D)
  • 4.Ensure your match_mode parameter is appropriate for your data type. Use 0 for exact matches with text or numbers; use 1 or -1 only for numeric data with approximate matching requirements.
  • 5.Test with a simple formula first before adding complexity. Start with =XLOOKUP(value, array1, array2) without optional parameters to isolate issues.
  • 6.Verify that your lookup_value actually exists in the lookup_array by using COUNTIF: =COUNTIF(lookup_array, lookup_value) should return at least 1 if matches exist.

Edge Cases

Lookup array contains duplicate values

Behavior: XLOOKUP returns the first match when search_mode is 1 (default) or the last match when search_mode is -1. Subsequent duplicates are ignored.

Solution: Use search_mode -1 to get the last occurrence, or add helper columns with COUNTIF to identify and handle duplicates explicitly.

This behavior differs from some users' expectations; always test with sample data containing duplicates.

Lookup value is found but return array cell is empty

Behavior: XLOOKUP returns an empty string ("") rather than triggering the if_not_found parameter. This is because a match was technically found, even though the return value is blank.

Solution: Use nested IF statements to check for empty returns: =IF(XLOOKUP(...)="", "No data", XLOOKUP(...)) or modify your data to include placeholder values.

This edge case often confuses users expecting if_not_found to trigger for empty cells.

Using XLOOKUP with array formulas or dynamic ranges from FILTER or UNIQUE functions

Behavior: XLOOKUP works seamlessly with dynamic array formulas, automatically adjusting as source data changes. This creates truly dynamic lookup systems.

Solution: Combine XLOOKUP with FILTER, UNIQUE, or SORT functions for sophisticated data retrieval that adapts to changing datasets without manual updates.

This represents one of XLOOKUP's most powerful capabilities for modern data analysis workflows.

Limitations

  • XLOOKUP is only available in Excel 365 and Excel 2021—organizations using Excel 2019 or earlier versions cannot use this function and must rely on VLOOKUP or INDEX/MATCH alternatives.
  • XLOOKUP cannot perform multi-criteria lookups directly; complex multi-field searches require helper columns, concatenation, or combination with other functions like FILTER, making formulas more complex.
  • Performance may degrade with extremely large datasets (millions of rows) when using entire column references (A:A) instead of specific ranges; binary search modes (2 and 3) require sorted data and may produce unexpected results if data is unsorted.
  • XLOOKUP's wildcard matching (match_mode 2) uses asterisks (*) and question marks (?) as wildcards, which may cause issues if your actual data contains these characters; you'll need to escape them with tildes (~) for literal matching.

Alternatives

Available in all Excel versions since 2007; widely understood and supported across organizations

When: Use VLOOKUP when working with older Excel versions or when your lookup column is to the left of your return column. Best for simple, straightforward lookups in standard table layouts.

More flexible than VLOOKUP; searches in any direction; handles complex scenarios; available in all Excel versions

When: Ideal for advanced users needing maximum flexibility, reverse lookups, or when working with Excel 2019 and earlier versions. Requires more formula complexity but offers superior functionality.

Returns entire rows or columns matching criteria; dynamic array formula; modern and intuitive

When: Use FILTER when you need to return multiple matching rows or when working with complex filtering logic. Available in Excel 365 and provides a cleaner alternative for multi-row returns.

Compatibility

Excel

Since Excel 365 (Microsoft 365 subscription) and Excel 2021

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

Google Sheets

Not available

LibreOffice

Not available

Frequently Asked Questions

Ready to master XLOOKUP and transform your Excel skills? Explore ElyxAI's comprehensive Excel formula training platform for interactive tutorials, real-world datasets, and expert-guided learning paths tailored to your proficiency level.

Explore Lookup and Reference

Related Formulas