Looks up values from another table
The XLOOKUP function is one of Excel's lookup and reference functions.
In modelling we use the XLOOKUP function to map data from one table into another based on a unique reference.
XLOOKUP is a much improved version of existing lookup methods such as VLOOKUP, HLOOKUP and INDEX MATCH.
The function includes an optional argument of what to return if no match is found. This removes the need for separate error management functions.
Let's take a look at a simple example of the XLOOKUP function.
We have a table of products and their prices.
In cell B7 we would like to return the price of the product that is entered in cell A7.
We would write the formula using XLOOKUP as follows:
Return the price of Lamb Pies from the product table.
Let's take a closer look at the structure of the arguments in the formula:
lookup - We want to find the price for Lamb Pie.
lookup array - We are looking for Lamb Pie in the range A2 to A5.
return array - The range B2 to B5 contains the product prices we want to choose from.
[not found] - Return the text "Not Found" if the lookup cannot be found in the lookup array
lookup - The value that you want to match.
lookup_array - The range of cells being searched through for the match value.
return_array - The range of cells that you want to return a value from.
[not_found] - Value to return if no match is found.
[match_mode] - Defines how the match should be performed:1 for next lower, -1 for next higher, 0 for exact match and 2 for a wildcard match.
[search_mode] - 1 for search from first (default), -1 for search from last,2 for binary search ascending, -2 for binary search descending.
Read more about the XLOOKUP function on the Microsoft support page here.