Home Resource Centre XLOOKUP In Excel: Understand The Usage With Practical Examples

Excel Blog Series Table of content:

XLOOKUP In Excel: Understand The Usage With Practical Examples

Excel has long been known for its powerful lookup functions like VLOOKUP and HLOOKUP. While these functions have been useful for retrieving data from tables, they had certain limitations, such as being unable to search to the left of the lookup column or requiring data to be sorted in a particular way. Enter the XLOOKUP function, a more advanced, flexible, and user-friendly replacement that addresses these shortcomings.

Introduced in Excel 365 and Excel 2021, XLOOKUP offers greater versatility and control over data retrieval. In this article, we will explore how to use the Excel XLOOKUP function, including its syntax and several practical examples to illustrate its full potential.

What is XLOOKUP?

XLOOKUP is a function in Excel designed to search for a specified value in one column or row, and return a corresponding value from another column or row. Unlike its predecessors (VLOOKUP and HLOOKUP), XLOOKUP can search in any direction: vertically or horizontally, and it does not require the lookup range to be sorted.

XLOOKUP simplifies the process of finding specific data within a spreadsheet by allowing users to specify the lookup value, the range to search within, the return range, and optional parameters for not found errors or search modes. This makes XLOOKUP a versatile and powerful tool for data analysis and manipulation in Excel.

XLOOKUP Formula Syntax

The syntax for the XLOOKUP function is as follows:

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

where:

  1. lookup_value: The value you are searching for.

  2. lookup_array: The range or array that contains the lookup_value.

  3. return_array: The range or array from which you want to return the result.

  4. [if_not_found] (optional): The value to return if no match is found. If not specified, the function will return an error.

  5. [match_mode] (optional): Specifies the type of match:

    • 0 for exact match (default),

    • -1 for exact match or next smaller value,

    • 1 for exact match or next larger value,

    • 2 for wildcard match.

  6. [search_mode] (optional): Specifies the search direction:

    • 1 for search from first to last (default),

    • -1 for search from last to first.

Comparing XLOOKUP in Excel with VLOOKUP and HLOOKUP

VLOOKUP searches vertically while HLOOKUP works horizontally. Both have limitations that XLOOKUP overcomes. For instance, VLOOKUP requires the lookup value to be in the first column of the range. XLOOKUP does not have this restriction. VLOOKUP cannot search backwards; XLOOKUP can search in any direction. This flexibility makes XLOOKUP more user-friendly and efficient.

Practical XLOOKUP Examples in Excel

Now that we understand the syntax, let’s look at some practical examples to see how XLOOKUP formula in Excel can be used in different scenarios.

Example 1: Basic XLOOKUP for Exact Match

Imagine you have a list of products and their prices, and you want to retrieve the price of a specific product.

Data (A1):

Product Price
Apple INR 20
Banana INR 15
Orange INR 30
Mango INR 50
Pineapple INR 100

To find the price of a "Mango," you can use the following formula:

=XLOOKUP("Mango", A2:A6, B2:B6)

This formula searches for "Mango" in the range A2 and returns the corresponding value from B2, which is INR 50

Example 2: XLOOKUP with Wildcards

In some cases, you may not know the exact value you're looking for but want to use a partial match. For instance, if you want to search for any product containing "Apple" in its name, you can use the wildcard match.

Assuming you have the following data:

Product Price
Apple Juice INR 50
Banana Shake INR 80
Mango Smoothie INR 100

To search for any product containing the word "Apple," you can use the wildcard character (*):

=XLOOKUP("*Apple*", A2:A4, B2:B4, "Not Found", 2)

This will return INR 50 for "Apple Juice" since it contains "Apple" in its name.

Example 3: XLOOKUP with Error Handling (if_not_found)

When performing lookups, you may encounter situations where the value you seek doesn’t exist. By using the [if_not_found] argument, you can return a custom message or value instead of an error.

Let’s say you’re searching for a product that might not be listed in your data:

=XLOOKUP("Grapes", A2:A6, B2:B6, "Product not found")

Since "Grapes" doesn’t exist in the data, the formula will return "Product not found" instead of the usual #N/A error.

Example 4: XLOOKUP for Approximate Match

In some cases, you may want to find the closest match rather than an exact match. For example, you might have a table showing tax rates for different income brackets, and you want to find the tax rate for a particular income.

Data (A1):

Income Tax Rate
0 10%
20000 15%
50000 20%
100000 25%
200000 30%

To find the tax rate for an income of INR 70,000, you can use an approximate match:

=XLOOKUP(70000, A2:A6, B2:B6, , -1)

This XLOOKUP formula will return 20%, as INR 70,000 falls between INR 50,000 and INR 100,000, and -1 ensures that it returns the next smaller value.

Example 5: XLOOKUP to Replace VLOOKUP with a Left Lookup

One of the key limitations of VLOOKUP is that it only works when the lookup column is to the left of the return column. XLOOKUP removes this restriction, allowing you to search to the left or right.

Consider the following data:

Price Product
INR 100 Apple
INR 50 Banana
INR 150 Mango

If you want to look up the product based on its price, which is to the right of the product column, you can use this formula:

=XLOOKUP(150, A2:A4, B2:B4)

This will return "Mango", as that is the product that corresponds to the price INR 150.

Example 6: XLOOKUP for Searching from Last to First

XLOOKUP also allows you to search from the last to the first item in your dataset, which can be useful in situations where you have duplicates and want to return the last occurrence.

If you have the following data:

Product Sales
Apple 100
Banana 150
Apple 200
Mango 180

To find the most recent sales figure for "Apple," you can use the following formula to search from last to first:

=XLOOKUP("Apple", A2:A5, B2:B5, , 0, -1)

This formula will return 200, which is the last occurrence of "Apple" in the list.

Implementation Tips for XLOOKUP In Excel

  • When using XLOOKUP, keep your data organized. Ensure that your lookup values are in a single column or row. This setup simplifies the search process and reduces errors.
  • Consider using error handling options within XLOOKUP. You can specify what to return if no match is found. For example, returning "Not Found" helps clarify results.
  • Test your formulas with sample data before applying them broadly. This practice allows you to catch any mistakes early on.
  • Remember to utilize relative and absolute references as needed. This approach ensures your formulas work correctly when copied across cells.

Closing Thoughts

XLOOKUP is a game-changer for your Excel tasks. It simplifies data retrieval, making your spreadsheets more efficient. By mastering its syntax and practical applications, you can enhance your productivity and accuracy. The important considerations highlighted ensure you avoid common pitfalls. Start using XLOOKUP today and unlock new possibilities for your data management!

Time For a Little Quiz!!!

  QUIZZ SNIPPET IS HERE
  QUIZZ SNIPPET IS HERE
  QUIZZ SNIPPET IS HERE

Frequently Asked Questions

Q1. What is XLOOKUP in Excel?

XLOOKUP is a powerful Excel function that replaces older functions like VLOOKUP and HLOOKUP. It allows you to search for a value in a range and return a corresponding value from another range.

Q2. How does XLOOKUP differ from VLOOKUP?

Unlike VLOOKUP, XLOOKUP can search both vertically and horizontally. It also allows for exact matches by default and handles errors more gracefully, enhancing usability.

Q3. What are the main arguments of XLOOKUP?

The main arguments of XLOOKUP are lookup_value, lookup_array, return_array, if_not_found, match_mode, and search_mode. Each argument customizes how the function searches and returns results.

Q4. Can XLOOKUP handle multiple criteria?

Yes, XLOOKUP can handle multiple criteria by using array formulas or combining it with other functions like FILTER. This flexibility enhances its capability for complex lookups.

Q5. Is XLOOKUP available in all Excel versions?

No, XLOOKUP is only available in Excel 365 and Excel 2021. Older versions do not support this function, so users must rely on alternatives like VLOOKUP or INDEX/MATCH.

Q6. What should I consider when using XLOOKUP?

When using XLOOKUP, consider data types and ranges. Ensure the lookup and return arrays are of the same size to avoid errors. Also, be mindful of performance with large datasets.

Q7. Where can I find practical examples of XLOOKUP?

Practical examples of XLOOKUP can be found within the Excel help documentation or various online tutorials. These resources provide step-by-step guides to help you master this function effectively.

Suggested Reads:

Shreeya Thakur
Content Team

I am a biotechnologist-turned-writer and try to add an element of science in my writings wherever possible. Apart from writing, I like to cook, read and travel.

Updated On: 3 Feb'25, 12:15 PM IST