0% found this document useful (0 votes)
10 views

XLOOkUP functions

The document provides an overview of the XLOOKUP function in Excel, highlighting its advantages over VLOOKUP and HLOOKUP, including its ability to search both vertically and horizontally and handle multiple criteria. It details the syntax, parameters, and various use cases for implementing XLOOKUP, such as performing exact and approximate matches, left lookups, and returning multiple values. Additionally, it compares XLOOKUP with VLOOKUP, emphasizing its robustness and efficiency in data retrieval.

Uploaded by

director.british
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

XLOOkUP functions

The document provides an overview of the XLOOKUP function in Excel, highlighting its advantages over VLOOKUP and HLOOKUP, including its ability to search both vertically and horizontally and handle multiple criteria. It details the syntax, parameters, and various use cases for implementing XLOOKUP, such as performing exact and approximate matches, left lookups, and returning multiple values. Additionally, it compares XLOOKUP with VLOOKUP, emphasizing its robustness and efficiency in data retrieval.

Uploaded by

director.british
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

XLOOKUP functions

XLOOKUP function in Excel

VLOOKUP and HLOOKUP function has their importance and popularity in Excel. One of the reasons for this
popularity is that earlier, there weren't available options whenever the user wanted to look up any value in Excel.
For complex formulas, they had to rely upon the INDEX MATCH combination. But not anymore!

With the new version of Excel, i.e., Excel 365 or Excel 2021, you no longer have to choose the above functions - as
Microsoft has introduced a more powerful and robust function that overcomes the annoying errors and all the
shortcomings of VLOOKUP, the XLOOKUP function.

In many ways, its better than other lookup functions. It can look vertically and horizontally, to the left or above,
capturing the ability to search with multiple criteria.

In this tutorial we will covering the following topics:

1. XLOOKUP Function: syntax, parameters, return value

2. Difference between VLOOKUP & XLOOKUP

3. How to implement XLOOKUP in Excel: examples

o XLOOKUP vertically and horizontally

o XLOOKUP to the left

o XLOOKUP with exact and approximate match

o XLOOKUP with wildcards

o XLOOKUP last match

o XLOOKUP and return multiple values (row or column)

o XLOOKUP with multiple conditions

o Two-way XLOOKUP

o If Error XLOOKUP

o Case-sensitive XLOOKUP

4. XLOOKUP Function not working

XLOOKUP Function: syntax, parameters, return value

"The XLOOKUP function in Excel looks at a range or an array for a given value and returns the corresponding value
from another column."

The advantage of using this function is that it can look up both the positions in your table, i.e., vertically and
horizontally, and can perform either an exact match (default), an approximate match (the closest data is found), or a
wildcard match (using wildcard characters a partial match is found).

Syntax
XLOOKUP functions

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

Parameters

1. Lookup_value (required) - This parameter represents the value to search for in the table.

2. Lookup_array (required) - This parameter represents the table or the range or array where to search.

3. Return_array (required) - It signifies the range or array from where the values will be returned.

4. If_not_found [optional] - This is an optional parameter that represent a value that will be returned if the
match is not found. In case you have skipped the parameter, the #N/A error is returned.

5. Match_mode [optional] - This parameter can accept four values depending upon your requirement; if you
skip this argument, by default, it takes 0 as its value and returns an exact match.

o 0 - You can enter this value if you want an exact match.

o -1 - You can enter this value if you are looking for an exact match or next smaller. It returns the next
smaller value, if it not founds and exact match.

o 1 - You can enter this value if you want to return an exact match or next larger value. If an exact
match is not found, the next larger value is returned.

o 2 - This value represents the wildcard character match.

6. Search_mode [optional] - This parameter helps the user to manage the direction of search. if you skip this
argument, by default, it takes 1 as its value and starts the search from first to last position of your array. It
can take the following values:

o 1 - Putting this value will start the search from first to last position of the defined array.

o -1 - Putting this value will start the search in reverse order i.e., from last to first position.

o 2 - This value is used if you want to have a binary search where the data is sorted in the ascending
order.

o -2 - This value is used if you want to have a binary search where the data is sorted in the descending
order.

Returns

The XLOOKUP function searches a range or an array for predefined value and it returns the related value from
another column.

How XLOOKUP Function works?

To understand the working of XLOOKUP function, we will utilize the lookup formula to perform an exact lookup.

For example, we have the names of 5 different salespersons and their monthly sales. Now using XLOOKUP, we have
to fetch the sales report of candidates. The name of the person will in cell B1 represents the lookup_value, and now
we will look at this value in our lookup_array (A2:A10), and on the basis, of the position, it will return the value from
the return array (B2:B10). Our formula becomes:
XLOOKUP functions

1. =XLOOKUP(F3,C2:C11,D2:D11)

No irritating problems with column index numbers, no sorting required, and no other headaches. Just one single
formula and you have your result!

XLOOKUP vs. VLOOKUP

Compared to traditional VLOOKUP, XLOOKUP has many advantages. Below given is a comparison table that lists the
differences between XLOOKUP and VLOOKUP:

S.No VLOOKUP XLOOKUP

The XLOOKUP function can look both ways in


The VLOOKUP function can only lookup
1 Excel worksheets, i.e., vertically and
your data vertically.
horizontally.

By default, the XLOOKUP function performs an


By default, the VLOOKUP function
2 exact match. Though, if needed you utilize this
performs an approximate match.
function to perform an approximate match too.

3 XLOOKUP

One of the most annoying problems with


The advantage of XLOOKUP is that here we
the VLOOKUP function is that inserting or
supply range not number, therefore we can
4 deleting columns breaks a formula
insert or delete as many columns as we require
because the return column is identified by
without using any column break.
its index number.

5 The primary drawback of the VLOOKUP The edge of the XLOOKUP function is that it
function is that it can slow down the only includes the lookup and return arrays that
operational speed of your worksheets contain the data.
because it takes the whole table in
XLOOKUP functions

calculations, eventually processing more


cells than required.

How to implement XLOOKUP in Excel: examples

Example 1: Look up vertically and horizontally

In earlier versions (before Excel 365), if users want to look up vertically or horizontally, they had to implement two
functions for different lookup types: VLOOKUP function to look vertically and HLOOKUP to look horizontally.

Luckily, with Excel 2021 or Excel 365, Microsoft introduced XLOOKUP function that is capable to perform both the
operations with a single syntax. All you need to do is to supply the respective lookup and return array.

For instance, below is the data sample, given with id, hospital items and their available status.

AD

Apply a VLOOKUP:

1. Type the below XLOOKUP formula.

1. Formula Used: =XLOOKUP(G4,B3:B9,C3:C9)


XLOOKUP functions

1. Press the enter. It will look for the product from the vertical table.

Applying a HLOOKUP:

1. Type the below XLOOKUP formula. With this, instead of supplying the data arrays vertically we will provide
horizontally.

1. Formula Used: =XLOOKUP(G4,B3:B9,C3:C9)


XLOOKUP functions

1. Press the enter. It will look for the product from the horizontal table.

Example 2: Perform left lookup using XLOOKUP

For earlier Excel versions, there wasn't any direct formula to look to the left in your data. You must combine
Index and Match functions to apply left lookup in your Excel worksheets. But with the XLOOKUP function,
you no longer need to combine Index and match functions. All you need to do is to specify the lookup table,
and XLOOKUP will handle the remaining task for you.

For instance, in the above data, we have added another column List_number to the left side. What if we are
given the product name and asked to look for the list_number?
XLOOKUP functions

We can use the XLOOKUP function to apply a left lookup in such cases. Follow the below steps to get a left
lookup:

AD

1. Type the XLOOKUP function and specify its parameters. The formula will as follows:

1. Formula applied: =XLOOKUP (F4,C3:C9,A3:A9)

1. Press the enter. It will quickly apply the left lookup and will fetch the output from the List_Number table.
XLOOKUP functions

Using the same steps, you can implement left lookup horizontally for rows!

Example 3: Perform exact and approximate match

In the beginning, of this tutorial, we have already covered the parameters used in XLOOKUP function. The
match_mode parameter controls the match behaviour. It holds four options:

o 0 - Enter this if you want an exact match.

o -1 - Enter this value if you are looking for an exact match or next smaller. It returns the next smaller value, if
it not founds and exact match.

o 1 - Enter this value if you want to return an exact match or next larger value. If an exact match is not found,
the next larger value is returned.

o 2 - This value represents the wildcard character match.

Exact match XLOOKUP

For most cases, you will use an Exact lookup in Microsoft Excel. Therefore, it's the default attribute, and if
you don't pass any value in the match_mode argument, implicitly, it will take 0. Consequently, you can
bypass match_mode and provide only the first three required parameters.

1. Type the XLOOKUP function and specify its parameters. The formula will as follows:

1. Formula applied: = =XLOOKUP(F4,C3:C9,B3:B9,"Not found",0)


XLOOKUP functions

1. Press the enter button. It will quickly apply the exact XLOOKUP lookup and fetch the output from the table.
Since 'Stop Ca' is not in our table, it will return "Not Found".

Approximate match XLOOKUP

To execute an approximate lookup match, you only need to set the match_mode parameter to -1 or 1,
depending on whether you want to return an approximate value for the next smaller or larger data.

For instance, here, we have taken a lookup table that lists the lower bounds of the grades. So, we set
match_mode to 1 to search for the next greater value when an exact match is not found:

1. Type the XLOOKUP function and specify its parameters. The formula will as follows:

1. Formula applied: = =XLOOKUP(F4,C3:C9,B3:B9,"Not found",1)

1. Press the enter button. It will quickly apply the exact XLOOKUP lookup and fetch the output from the table.
Since 'Stop Ca' is not in our table, therefore it will look for next greater value and will return the ID number
of Stop Cap.
XLOOKUP functions

Example 4: To match partial data (wildcards)

XLOOKUP provides the option to execute a partial match lookup. All you need to do is to set the
match_mode parameter to 2. Primarily, most of the users prefer to use the following wildcard characters:

1. An asterisk (*) - This wildcard character is used to define the sequence of characters.

2. A question mark (?) - This wildcard character is used to define any single character.

Let's implement the partial match using a real-time example.

The above table lists phones' features, storage, price, display, etc. You are interested in the price of a certain
smartphone. The only problem here is you only know about the phone name, not the complete model
name, exactly as it appears in column A. The solution is to enter the phone name and replace the front and
back characters with wildcards.

Let's suppose we want to fetch information about the price of Samsung formula, we will incorporate the
following formula with wildcard characters and will set the match_mode argument to 2:

1. Formula Applied: =XLOOKUP("*"&C10&"*",A3:A7,B3:B7,,2)


XLOOKUP functions

The above formula will return the pricing after partially matching Samsung from the table:

Note: Instead of a cell reference, you can also directly pass the phone name between the double inverted
commas (" ").

1. Formula Applied: =XLOOKUP("*samsung*",A3:A7,B3:B7,,2)

Example 5: Work in Reverse order to get last occurrence

Sometimes, your lookup table contains multiple instances of the lookup value. By default, the XLOOKUP
formula fetches the matched output of the first occurrence of the lookup value. But what if you want to
return to the last match? To have it done, all you need to do is to set the Xlookup formula to search in the
reverse direction.

You can control the order of the search by the 6th parameter named search_mode:

o 1 (default value)- Enter this if you want to set your search from first to last value.

o -1 - Use this if you want to set your search in reverse order or want to fetch the last to first value.

For example, let's implement the XLOOKUP formula to return the last sale value of the product 'STERI SET'.
Unlike the above formulas, we put together the first three required arguments (E3 for lookup_value
argument, B2:B11 for lookup_array, and C2:D11 for return_array argument), and this time will set the 5th
parameter to -1.

1. Formula Applied = XLOOKUP(E3,B2:B11,C2:C11,,,-1)


XLOOKUP functions

As a result, it will search for the last occurrence of the lookup_value "STERI SET" and will return the lowest
pricing.

Example 6: Return multiple columns or rows

Do you know the XLOOKUP function is not limited to returning a single value? Using this formula, you can
return more than one value associated with the same lookup_value. And to implement, you need to enter
only the first three required arguments without any additional manipulations!

As an example, suppose from the above table (Data of Smartphones) you are asked to fetch all the details of
a specific phone. The formula to implement this is very simple. Instead of a single column, what you need to
do is supply the entire range (B1: G6) for the return_array parameter:

1. Formula Applied = XLOOKUP(C9,A1:A6,B1:G6)


XLOOKUP functions

All you need to do is to enter the formula, and Ms. Excel will automatically spill the output into adjacent
blank cells. In our case, it has returned all six columns. Refer to the following output:

Using the Transpose function, you can also return the above output vertically in a column. Nesting the
XLOOKUP into Transpose will automatically flip the array vertically.

1. Formula Applied = TRANSPOSE(XLOOKUP(C9,A1:A6,B1:G6))

You will have the following output:


XLOOKUP functions

Note: Before using this formula, ensure you have enough empty cells towards the right or downside of the
formula cell. Because multiple values are adjusted into neighboring cells, if Excel finds any data, it will return
a #SPILL! error.

Example 7: XLOOKUP Multiple Criteria

One more amazing feature of XLOOKUP is that it handles arrays natively. Because of this feature it can easily
work with multiple criteria directly in the lookup_array parameter. Follow the below syntax for multiple
criteria:

1. XLOOKUP (1, (criteria_range1=criteria1) * (criteria_range2=criteria2) * (...), return_array)

The output of each criteria is an array of either TRUE or FALSE values. But since we are multiplying the
arrays, the TRUE or FALSE Boolean values get converted into 1 and 0, respectively, generating the resultant
lookup array. As per the basic maths rule, if you multiply anything with 0, the output will always be zero;
therefore, in the lookup table, only the items that meet all the criteria are represented by 1.

You can check in the below table that we are given three criteria to check. Based on those criteria we have
figure out the Sales from E2:E11 (return_array).

We will be applying three criteria's which are as follows:

1. Criteria1 (sales_person) = H2

2. Criteria2 (List_number) = H3
XLOOKUP functions

3. Criteria3 (Products) = H4

The formula takes this shape:

1. Formula Applied = XLOOKUP(1,(D2:D11=H2)*(A2:A11=H3)*(B2:B11=H4),E2:E11)

As a result, the XLOOKUP function will process all the criteria, and if each criterion is fulfilled, it will look for
the output from the return array.

Example 8: Double (Two Way) XLOOKUP

Two-way or Double lookups are commonly used to find the intersection value of a given row and column. To
your surprise, Excel XLOOKUP can do that too! All it requires is to nest XLOOKUP into another, and you will
have the following syntax:

1. XLOOKUP(lookup_value1, lookup_array1, XLOOKUP(lookup_value2, lookup_array2, data_values))

For this example, we are given Sales_Report of three months i.e., S1, S2, S3. Here, we will find the sales
report of a particular salesperson within S3 quarter. To solve the problem, we will use two-way Xlookup with
the following formula:

1. Formula Applied=XLOOKUP(I2,C2:C11,XLOOKUP(I3,D1:F1,D2:F11))

Example 9: Case-sensitive XLOOKUP

In the above examples, you might have noticed that the XLOOKUP function treats the lowercase and
uppercase letters as same. By default, this function is case-sensitive. To make XLOOKUP case-sensitive, we
will replace the parameter lookup_array with the EXACT function. Use the following syntax:

1. XLOOKUP(TRUE, EXACT(lookup_value, lookup_array), return_array)


XLOOKUP functions

As the name suggests, the role of the EXACT function is to compare the given lookup value to each value in
the array; if it gets matched (including the letter case), it returns TRUE. Now, XLOOKUP matches its lookup
value with its lookup array, and if both are TRUE, it searches the TRUE for the given array and returns the
match from the return array.

Let's suppose we want to fetch Sales data of product STERI SET with a Case-sensitive match, we will be using
the following formula:

1. Formula Applied: =XLOOKUP(TRUE, EXACT(E3, B2:B11), C2:C11, "Not in the list!")

Since it found an exact found, it will return the sales value from the return array,

Note. If your lookup array contains two or more same data, the XLOOKUP function will return the first match
value.

Example 10: If Error XLOOKUP


XLOOKUP functions

The XLOOKUP function returns the #N/A error if the lookup value is not found. While using the formula
professionally, the #N/A error doesn't look good and could even be confusing for many intermediate Excel
users. Therefore, catching the error and writing a user-friendly note are always advised.

For example, let's consider a case when the match is not found.

As a result, you got an #N/A error. To replace the error with your customized message, you need to add a
text in the fourth argument.

1. Formula Applied: = =XLOOKUP(F3,C2:C11,D2:D11,"Invalid Name")

For instance, if someone inputs an invalid product name, our formula will return "Invalid name" message.

You might also like