Avoid XLOOKUP Errors

This article will help you navigate the waters of common XLOOKUP errors and issues. We’ll first begin by identifying errors, issues, and unexpected results. Then we’ll talk about specific ways to avoid and address each one. I hope this article will help you be able to use this wonderful function more effectively in your workbooks!



There’s no denying that outstanding XLOOKUP skills can empower us to be more efficient with Excel. However, as we begin to work with XLOOKUP more often, inevitably, we encounter errors with our data. This blog post provides a detailed walkthrough on troubleshooting common XLOOKUP errors, enabling us to level up our Excel proficiency.

Exercise 1: Data Type Mismatch

A frequent issue with XLOOKUP is related to data types—specifically, text versus numbers.

Imagine we enter an invoice number into cell C7, and we’d like to write a formula in C8 that uses XLOOKUP to retrieve the amount from the related data range. The worksheet may look something like this:

So, we write the following formula into C8:

=XLOOKUP(C7, B13:B20, E13:E20)

To our surprise, the formula returns an error, as shown below:

We double check the formula and function arguments, and it seems correct. So, what’s up … why the error?

This type of error is related to data types. This is a common gotcha to be aware of.

The invoice number in C7 is being stored as a number. However, the invoice numbers in the lookup range B13:B20 are being stored as text values. And equivalent values, when stored as different data types, do not match in XLOOKUP. Excel may store numbers as text when we import data from external sources, copy/paste, or if the cell formatting is text before the values are entered.

To resolve this, we could manually convert the text values to numbers. However, another option involves modifying our formula. By wrapping the VALUE function around our lookup range, Excel will convert the text strings into numeric values during formula evaluation, ensuring a successful match.

The updated formula looks like this:


We hit Enter, and bam:

Another common issue with XLOOKUP is how to handle multiple matches. So let’s dig into that next.

Exercise 2: Multiple Matches

Let’s consider another common issue: multiple matches. When we use XLOOKUP, it stops at the first match and returns that result. This behavior is fine for some cases but not for others where we might need the last match or all matching values.

For instance, our formula in C8 might be:


When there are multiple matches, it returns the first related amount:

In some cases, this may be what we want. In other cases, we may want to return the last match or all matches.

If we want to return the last match instead of the first, we can modify our formula to set the Search Mode argument to -1, which searches last to first, as follows:


The formula returns the last matching value in the range:

So, when we want to return the first or last matching result, XLOOKUP is beautiful. But, what if we want to return all matching values? Let’s tackle that next.

Exercise 3: Returning All Matches

Although XLOOKUP isn’t designed to return all matching rows, the FILTER function is 🙂

For example, the following formula:


Returns all matching amounts:

Now, if instead of seeing all of the matched values, what if we want to aggregate the results? To do so, we can wrap the desired aggregate function around the FILTER function. For example, to sum the results:


To find the largest or max value within the filtered results:


To find the smallest or minimum value within the filtered results:


To find the average:


And well, you get the idea.

Wrapping Up

These are just a few examples of how to handle common XLOOKUP issues. By understanding and applying these techniques, we can ensure our data lookup processes are smooth and error-free. Thank you for joining us on this journey through XLOOKUP errors. We hope you found it helpful and encouraging. Have a great day!

Sample file


Q: What is the most common issue encountered with XLOOKUP?

A: One of the most common issues with XLOOKUP is a data type mismatch, where numeric values are being compared to text values that appear as numbers. This can cause errors in the lookup process.

Q: How can I resolve a data type mismatch error in XLOOKUP?

A: You can resolve a data type mismatch error by converting text values to numeric values using the VALUE function. For example: =XLOOKUP(1022, VALUE(B13:B20), C13:C20).

Q: What should I do if XLOOKUP returns the first match, but I need the last match?

A: To find the last match, modify your XLOOKUP formula to search from the bottom up by specifying the search mode with -1. For example: =XLOOKUP(1022, A2:A10, B2:B10, , , -1).

Q: Can XLOOKUP return all matching values for a given lookup value?

A: XLOOKUP is not designed to return all matching values, but you can use the FILTER function to achieve this. For example: =FILTER(C2:C10, A2:A10 = 1022).

Q: How can I sum all values returned by the FILTER function?

A: You can use the FILTER function combined with the SUM function to sum all matching values. For example: =SUM(FILTER(C2:C10, A2:A10 = 1022)).

Q: Is it possible to find the maximum or minimum value within the FILTER results?

A: Yes, by using the FILTER function in combination with the MAX or MIN functions. For example, to find the maximum value: =MAX(FILTER(C2:C10, A2:A10 = 1022)). For the minimum value: =MIN(FILTER(C2:C10, A2:A10 = 1022)).

Posted in ,

Jeff Lenning

I love sharing the things I've learned about Excel, and I built Excel University to help me do that. My motto is: Learn Excel. Work Faster.

Excel is not what it used to be.

You need the Excel Proficiency Roadmap now. Includes 6 steps for a successful journey, 3 things to avoid, and weekly Excel tips.

Want to learn Excel?

Our training programs start at $29 and will help you learn Excel quickly.

Leave a Comment