Contents
- 1 Excel XLOOKUP Function
- 2 When to Use the Excel XLOOKUP Function in Excel
- 3 What Excel XLOOKUP Function Returns
- 4 Syntax of Excel XLOOKUP Function
- 5 Input Arguments
- 6 Examples of the Excel XLOOKUP Function
- 6.1 Example 1: Basic Usage (Exact Match)
- 6.2 Example 2: Find and Fetch an Entire Record
- 6.3 Example 3: If the lookup value is not found
- 6.4 Example 4: Approximate match using XLOOKUP
- 6.5 Example 5: Specifies the search order – first to last or last to first
- 6.6 Example 6: Two-Way Lookup with XLOOKUP (Lookup in Both Horizontal and Vertical Directions)
- 7 Extra Notes
- 8 Time to Apply Your Knowledge.
- 9 Conclusion
- 10 Frequently Asked Questions (FAQs)
Excel XLOOKUP Function
When to Use the Excel XLOOKUP Function in Excel
Excel XLOOKUP Function1 is a powerful tool for finding and fetching data in tables or ranges. It is especially handy when you want to locate a specific value in a dataset and get the corresponding value from another range.
What makes XLOOKUP better than VLOOKUP, HLOOKUP, and LOOKUP?
Well, XLOOKUP is more versatile and easier to use. It works for both horizontal and vertical searches, so you don’t need separate functions like VLOOKUP and HLOOKUP. Plus, it is super flexible, handling both exact and approximate matches.
In simple terms, if you want a quick and efficient way to find and retrieve data in Excel, XLOOKUP is your go-to choice.
What Excel XLOOKUP Function Returns
The Excel XLOOKUP function returns a value corresponding to the match found in a specified range.
Syntax of Excel XLOOKUP Function
The syntax of the Excel XLOOKUP function is as follows:
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
Input Arguments
Here are the input arguments for the Excel XLOOKUP function:
● lookup_value: The value to search for in the lookup_array.
● lookup_array: The range or array containing the values to be searched.
● return_array: The range or array containing the corresponding values to be returned.
● [if_not_found]: The value to return if no match is found (optional).
● [match_mode]: Specifies whether to perform an exact or approximate match (optional).
- 0 = exact match (default),
- -1 = exact match or next smallest,
- 1 = exact match or next larger,
- 2 = wildcard match.
● [search_mode]: Specifies the search order – first to last or last to first (optional).
- 1 = search from first (default),
- -1 = search from last,
- 2 = binary search ascending,
- -2 = binary search descending.
Note: Excel XLOOKUP function is exclusively accessible in Microsoft 365’s Excel and Excel for the web. It is not supported in pre-dynamic array versions of Excel (Excel 2019 and earlier) because they do not support array constants. To learn more about how to use Excel for Web for free. Watch 👇 this video
How to Get Microsoft Excel for Free | Free Microsoft Office | Microsoft Office 365
Examples of the Excel XLOOKUP Function
Here are a few examples of using the Excel XLOOKUP function:
Example 1: Basic Usage (Exact Match)
Imagine you have the dataset below, and you wish to fetch the salary for Employee ID 105 (lookup_value). The formula below accomplishes this:
In the formula above, we only used the required arguments of Excel XLOOKUP function. It looks for the Emp ID from A2:A11, finds an exact match, and gives back the matching value from D2 to D11.
A good thing about having the lookup_array and return_array as separate arguments is that now you can also look to the left. VLOOKUP could only find values to the right, but with Excel XLOOKUP Function, that is not a problem anymore.
Now, you will notice in the image below that our lookup array (Emp ID) is on the right side, and the result array (Name) is on the left side. If we want to find the name using the employee ID, we will use the following formula:
Excel XLOOKUP Function solves a big problem. If you add a new column or change the order of columns, the data will still be right. VLOOKUP might not work correctly in such situations because it often relies on fixed column numbers.
Example 2: Find and Fetch an Entire Record
Using the same data as an example, this time, I don’t just want to retrieve a single piece of information; I want to gather all the records.
Here is the explanation: =XLOOKUP(A3, A6:A15, B6:D15)
- A3: This is the value you are searching for. The XLOOKUP function is looking for the value in cell A3.
- A6:A15: This is the range in which XLOOKUP searches for the value (A3). It looks in the cells A6 through A15.
- B6:D15: This is the range from which XLOOKUP returns the corresponding value. If a match is found in the range A6:A15, the function will return the corresponding value from the corresponding row in the range B6:D15.
Example 3: If the lookup value is not found
In the image below, you can see that if the lookup value is not found in the lookup array, the formula shows an error.
So, if the lookup value is not found, you can utilize the fourth argument, [if_not_found], of the Excel XLOOKUP function to decide what message to write.
The below formula will do this:
In the example above, we manually specified the desired outcome if no match is found. Alternatively, you can use a cell reference to point to a specific cell or use a formula.
Example 4: Approximate match using XLOOKUP
Let’s explore an example demonstrating the Excel XLOOKUP function in approximate match mode.
XLOOKUP introduces a significant enhancement by offering four match modes, unlike VLOOKUP with two and MATCH with three.
- 0 = exact match (default),
- -1 = exact match or next smallest,
- 1 = exact match or next larger,
- 2 = wildcard match.
You can choose any of these four modes by specifying the corresponding argument to determine how the lookup value should be matched.
Below, you can observe a comprehensive display of various formulas for the match mode, all captured in a single image.
Don’t be confused by seeing so many formulas together; I will explain each one in detail, step by step.
Formula 1 : =XLOOKUP(F2,A2:A11,D2:D11, ,-1)
In the above formula, we omitted the fourth argument [if_not_found], and in the fifth argument [match_mode], we specified -1 for an exact match or the next smaller value.
XLOOKUP formula is searching for the Emp ID ‘300’ in the range of Emp IDs (A2:A11) and, if an exact match is not found, it returns next smaller corresponding salary from the range of Salaries (D2:D11).
In this case, the Emp ID ‘300 is not present in the given dataset. The formula then returns the closest Emp ID less than 300 and provides the corresponding salary, which is 51000 for Employee ID 251.
Formula 2 : =XLOOKUP(F2,A2:A11,D2:D11, ,1)
In the fifth argument [match_mode], we specified 1 for an exact match or the next larger value.
The formula then returns the closest Emp ID larger than 300 and provides the corresponding salary, which is 70000 for Employee ID 315.
Formula 3 : =XLOOKUP(“Ja*”,B2:B11,D2:D11,,2)
In the fifth argument [match_mode], we specified 2 for a Wildcard character match
This formula employs a wildcard character (*) in the lookup value “Ja*”. It searches for names in the range of Names (B2 to B11) that start with “Ja” and may have any characters following. If a match is found, it returns the (first match) corresponding salary from the Salaries column (D2 to D11).
The result is 55000, which is the salary corresponding to the Name “Jane”. The wildcard character (*) enables a partial match based on the specified pattern.
The great advantage is that you no longer have to concern yourself with whether your data is arranged in ascending or descending order. Excel XLOOKUP function seamlessly handles unsorted data.
Example 5: Specifies the search order – first to last or last to first
Normally, XLOOKUP search from the first to the last. If you want it to look from the last to the first, just put -1 in the sixth argument [search_mode] (like in the example below).
It means that XLOOKUP function should find the value from last to first and match it from the end of the lookup array.
Example 6: Two-Way Lookup with XLOOKUP (Lookup in Both Horizontal and Vertical Directions)
Imagine you have a student report card dataset with names, Math scores, Science scores, and English scores. Now, you want to dynamically find and display the score of a specific subject for a particular student. In this case, we want to find Lisa’s English score, so we will use the following formula:
Here is the explanation: =XLOOKUP(G2,A3:A12,XLOOKUP(G3,B2:D2,B3:D12))
This formula uses a Nested XLOOKUP, where first we use it to fetch all the marks of the subject in cell G3
So the result of =XLOOKUP(G3,B2:D2,B3:D12) is {92,69,59,75,93,54,61,58,65,78}, which is an array of English score in this case.
This is used again in the outer XLOOKUP formula as the part that gives back the answer. In this outer XLOOKUP, we look for the student’s name (in cell G2), checking in the range from A3 to A12.
In this case student’s name is Lisa (who is in the fourth position), this outer XLOOKUP formula retrieves the fourth value from the return array, which, in this example, is {92,69,59,75,93,54,61,58,65,78}.
The advantage of using this two-way lookup is that the result doesn’t depend on the student or subject name. If I switch the subject to Math, this XLOOKUP formula would still function correctly and provide the accurate result.
Extra Notes
● If the [if_not_found] argument is omitted, the function returns an #N/A error if no match is found.
● XLOOKUP supports both horizontal and vertical lookup.
● The lookup_array and return_array in XLOOKUP must be the same sizes. If not, XLOOKUP shows an error: #VALUE!
● If XLOOKUP looks at an Excel Table in another file, that file must be open. If not, XLOOKUP shows an error: #REF!
● XLOOKUP can find data on the right or left side of the lookup values.
● XLOOKUP can perform a reverse search (from last to first).
● XLOOKUP can return whole rows or columns, not just one value.
Time to Apply Your Knowledge.
Take a hands-on approach to mastering the Excel XLOOKUP function. Utilize the provided Excel file to experiment and witness its functionality with sample data.
Should you have any questions or stumble upon intriguing insights, don’t hesitate to share your thoughts in the comments. Embrace the learning journey with practical experience!
Note :There are four different sheets in the file
Conclusion
In conclusion, the Excel XLOOKUP function is a game-changer for data lookup and retrieval tasks. Its flexibility, ability to handle both exact and approximate matches, and support for dynamic arrays make it a must-have tool for Excel users dealing with large datasets.
As you incorporate XLOOKUP into your Excel arsenal, you will find that it streamlines your workflow and provides a more efficient way to search and retrieve information. Don’t hesitate to explore its various options and unleash its full potential in your data analysis projects.
Frequently Asked Questions (FAQs)
Q1: Can Excel XLOOKUP function perform case-sensitive searches?
A1: No, XLOOKUP function considers lowercase and uppercase letters as equivalent characters.
Q2: Does XLOOKUP only work in Excel 365 and Excel 2019?
A2: It is available in Excel 365, it is not available in Excel 2019.
Q3: Can XLOOKUP handle multiple criteria for lookup?
A3: Yes, XLOOKUP can handle multiple criteria by using arrays as lookup values and arrays as return values.
Q4: Is XLOOKUP more efficient than VLOOKUP and HLOOKUP?
A4: Yes, XLOOKUP is generally considered more efficient and versatile than VLOOKUP and HLOOKUP, especially when dealing with large datasets and dynamic arrays.
Q5: Can XLOOKUP be used for reverse lookup (finding the lookup_value based on the known return_array value)?
A5: Yes, XLOOKUP can be used for reverse lookup by swapping the positions of the lookup_array and return_array.
Other Related Excel Functions
Excel WRAPROWS Function: A Comprehensive Guide to Organizing Data Row-Wise
Mastering Data Transformation: A Guide to Excel TOROW Function for Effortless Row Arrangement
Mastering Excel FILTER Function: A Comprehensive Guide for Data Filtering
Join me on Instagram, YouTube and WhatApp Channel for your daily dose of valuable tips and tricks! Catch insightful videos that will enhance your knowledge and skills. Don’t miss out – follow me now!