The XLOOKUP function in Excel is a powerful and flexible tool designed to replace older lookup functions like VLOOKUP and HLOOKUP. Unlike these traditional functions, XLOOKUP can search both vertically and horizontally, making it ideal for retrieving specific values from any range in a table. With added benefits like default exact matching and the ability to handle errors more gracefully, XLOOKUP makes data retrieval in Excel easier and more reliable.
In this article, we will cover how XLOOKUP works, its syntax, and practical examples to help you make the most of this versatile function.
XLOOKUP Function in Excel With ExamplesWhat is XLOOKUP in Excel
XLOOKUP is a powerful function in Excel designed to search for a specific value in a range and return a corresponding value from another range. It replaces older functions like VLOOKUP and HLOOKUP, addressing their limitations by allowing for more flexible searches, including reverse lookups and partial matches.
XLOOKUP Formula in Excel with Example
=XLOOKUP(lookup_value, lookup_array, return_array, [if _not_found], [match_mode], [search_mode])
=XLOOKUP(search for this value, in this range, and Return a match from this range).
Arguments Explained
- lookup_value: The value you want to search for.
- lookup_array: The range of cells where Excel will search for the lookup value.
- return_array: The range of cells from which to return the result.
- if_not_found (optional): Value to return if no match is found.
- match_mode (optional): Specifies the type of match (exact, approximate, or wildcard).
- search_mode (optional): Determines the search direction (first-to-last or last-to-first).
Match Type | Behavior |
---|
0 (default) | Here it will look for an exact match |
-1 | If we do not get the exact match then it will return the next smaller item. |
1 | If we do not get the exact match then it will return the next larger item. |
2 | It will do partial matching using (* or ~) |
- search_mode (Optional): where we can specify how the function should look up the value.
Search mode | Behavior |
---|
1(default) | It will search the values first. |
-1 | It will search the values in reverse from last. |
2 | It will perform a binary search and data needs to be sorted in ascending order. |
-2 | It will perform a binary search and data needs to be sorted in descending order. |
How to Enable XLOOKUP in Excel
To access the XLOOKUP function in Excel, you need to be using a version of Excel that supports it.
How to Enable XLOOKUP in Excel 365
XLOOKUP is included in Excel 365, which is a subscription-based version of Excel that receives regular updates and new features.
How to Enable XLOOKUP in Excel 2019
XLOOKUP was introduced in Excel 2019, which is a one-time purchase version of Excel. However, it might not be available in older versions of Excel, such as Excel 2016 or earlier.
Step-by-Step Guide to Using XLOOKUP in Excel
Step 1: Open Excel
Start by opening your Excel application and loading the worksheet containing your data.
Step 2: Select a Cell
Click on an empty cell where you want to display the result of your XLOOKUP function.
- Type
=XLOOKUP(
into the selected cell. Excel will prompt you with a list of arguments.
Step 4: Enter Required Arguments:
- lookup_value: Specify the value you are searching for (e.g., a cell reference like A2).
- lookup_array: Select the range where Excel should look for this value (e.g., B2:B10).
- return_array: Choose the range from which you want to retrieve data corresponding to the found value (e.g., C2:C10).
Example formula:
=XLOOKUP(A2, B2:B10, C2:C10)
Optional Arguments:
- If desired, add optional arguments such as
if_not_found
to handle cases where no match is found. - Use
match_mode
to specify how closely you want Excel to match your lookup value (0 for exact match, 1 for next largest, etc.). - Set
search_mode
if you want to control whether it searches from first to last or vice versa.
Close the parentheses and press Enter. Your formula should now return the corresponding value based on your criteria.
XLOOKUP Example in Excel: 6 Examples Explained
Below are some examples through which the XLOOKUP function will be easily understandable.
Example 1: Using XLOOKUP for Exact Matches
This function in XLOOKUP is by default. Follow the below steps to Lookup a value:
Enter you DataNow, if we want to get the math marks of Carry then follow the next step
We will enter =XLOOKUP(E2, A2:A5, B2:B5) in the F2 cell to get the marks of carrying.
Enter the Formula Then we will get the math marks for carry.
Example 2: How to Approximate Match in Excel
If you want to find the closest (approximate) match to a specified value, use match mode -1 (next smaller) or 1 (next larger):
Let's consider the below example for Approximate match mode.
Format your Data
Formula used is : =XLOOKUP(lookup value, in this range, Return a value from this range, -1)
Here -1 will return the approximate value which is smaller than the lookup value.
Note: The user can also use 1 instead of -1 to return a value larger than the lookup value. The XLOOKUP function can also work for Unsorted data.
Example 3: How to Use Left Lookup in Excel
Unlike VLOOKUP, XLOOKUP can perform a left lookup, allowing you to search for values on the left side of the data:
Using INDEX and MATCH in Excel left lookup can be performed but to make it simple and quick you can also use the XLOOKUP function. This XLOOKUP function is used to search the values which are on the left side of the searched values.
The formula used: = XLOOKUP(Search for this value, from this range, and return the output from this range)
Here the output we are looking for will be from the left side of the column.
Example 4: How to Use XLOOKUP on Multiple Values
You can combine XLOOKUP with additional functions for more complex lookups. To retrieve a value based on multiple conditions, use concatenation or an array formula:
Enter and Format your Data Now, if we want to get the Math and English marks for carrying then follow the next step
We will enter =XLOOKUP(E2,A2:A5,B2:C5) in F2 cell.
Enter the Formula Step 3: Marks Obtained
Then we will get the Math and English marks.
Marks ObtainedExample 5: How to Use Nested XLOOKUP function in Excel
Follow the below steps to use nested XLOOKUP functions:
Format your DataNow, if we want to get the math marks of Carry by two-way lookup then follow the next step.
We will enter =XLOOKUP(F1,B1:C1,XLOOKUP(E2,A2:A5,B2:C5)) in F2 cell.
Here, XLOOKUP(E2, A2:A5, B2:C5) is{100,80} which is an array mark of Carry. In the outer XLOOKUP formula, we are looking for the subject name which is in the F1 cell and the lookup array is B1:C1.
Enter the Formula Step 3: Marks Displayed
Then we will get the math marks of carry.
Marks DisplayedExample 6: How to Use Not Found in Excel
Follow the below steps when the LOOKUP function returns the Not Found message:
Format your DataIf we want the marks of Sunny who is not in the dataset
We will enter =XLOOKUP(E2,A2:A5,B2:B5,"Not Found") in F2 cell.
Enter your DataStep 3: Not Found Displayed
Then it will show Not Found.
Not Found DisplayedExample 4: How to Use SUM function in Excel
Follow the below steps to find the sum of a range:
Format your DataIf we want the total math marks from Harry to Jonny then do the next step
We will enter =SUM(XLOOKUP(E2,A2:A5,B1:B6):XLOOKUP(F2,A2:A5,B1:B6)) in G2 cell this simply means =SUM($B$2:$B$5).
Enter your FormulaStep 3: Sum Displayed
Then we will get the sum.
Sum DisplayedExample 5: How to Use Horizontal Lookup in Excel
Format your DataNow, if we want to get the math marks of Carry then follow the next step
We will enter =XLOOKUP(B6,B1:E1,B2:E2) in B7 cell.
Format your DataStep 3: Carry Marks Displayed
Then we will get the math marks of Carry
Carry Marks ObtainedExample 6: How to Use Last Match in Excel
Follow the below steps to use last match in Excel:
Step 1: Enter your data
By default, the XLOOKUP Function performs a top-to-bottom search. But if the user wants to change this order and search for the bottom to top then the formula should be: =XLOOKUP(Search for the value, in this range, return the output from this range, -1)
Note: -1 in this formula should be the 6th parameter)
XLOOKUP Vs VLOOKUP: Key Differences
XLOOKUP and VLOOKUP are Excel functions used for finding information in a table, but they have differences:
Feature | XLOOKUP | VLOOKUP |
---|
Lookup Type | More versatile, handles both vertical and horizontal lookups. | Primarily for vertical lookups. |
Syntax | Easier syntax, with no need to specify column numbers. | Requires specifying column index, which can be cumbersome. |
Error Handling | Built-in error handling with custom error messages. | Basic error handling using the "IFERROR" function. |
Search Flexibility | Supports wildcards for flexible searches. | Defaults to exact matches; requires extra steps for approximate matches. |
Return Values | Can return arrays of values. | Returns a single value, not suitable for multiple matches. |
Dataset Compatibility | Works well with large datasets and dynamic arrays. | Limited to simpler tasks and smaller datasets. |
Overall | More user-friendly and powerful, especially for complex tasks. | Simpler but has limitations. |
Note: XLOOKUP is more versatile and user-friendly, especially for complex datasets and lookups across multiple columns or rows.
Advanced XLOOKUP Techniques
- Nested XLOOKUP: Use XLOOKUP within another XLOOKUP for two-way lookups.
- Horizontal Lookups: Perform searches across rows instead of columns.
- Using XLOOKUP for Summation: Calculate totals over a specified range using XLOOKUP with SUM.
Conclusion
In conclusion, XLOOKUP is a revolutionary addition to Excel that addresses the limitations of VLOOKUP and HLOOKUP. By mastering XLOOKUP, you can perform efficient data searches, streamline your workflow, and enhance your overall productivity. Whether you're a financial analyst, data scientist, or small business owner, leveraging XLOOKUP in your daily tasks will save you valuable time and effort.
Similar Reads
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
What is Vacuum Circuit Breaker? A vacuum circuit breaker is a type of breaker that utilizes a vacuum as the medium to extinguish electrical arcs. Within this circuit breaker, there is a vacuum interrupter that houses the stationary and mobile contacts in a permanently sealed enclosure. When the contacts are separated in a high vac
13 min read
Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi
6 min read
Python Variables In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, Python variables do not require explicit declaration of type. The type of the variable i
6 min read
Spring Boot Interview Questions and Answers Spring Boot is a Java-based framework used to develop stand-alone, production-ready applications with minimal configuration. Introduced by Pivotal in 2014, it simplifies the development of Spring applications by offering embedded servers, auto-configuration, and fast startup. Many top companies, inc
15+ min read