XLOOKUP returning #N/A for some values when the values are there

Copper Contributor

I am trying to use XLOOKUP to find an identifying number from a separate spreadsheet, referenced by a different identifying number. My equation works for the most part, but I have a few #N/A errors (3 out of 11), but I have confirmed that the values were present in the array and that there were no typos. 

 

I cannot share a screenshot, so I will give a simplified version using sheets WS1, WS2, and WS3 with values ID1 and ID2. WS1 is the active sheet I am writing the formula in

 

ID1 =VLOOKUP(A2,WS2,ID1Column,false (This equation works with no issues)

ID2 = XLOOKUP(ID1Value,WS2LookupArray,WS2ReturnArray)

ID2 equation works for the majority of the time, but returns a few #N/A and I cannot figure out why. I have run trim to eliminate any extra spaces, I formatted all cells the same way, I have no idea why I cannot get the error cells to work. 

5 Replies

@jgans The LOOKUP functions are sensitive to the data-type on both ends. They will only find a match if both the looked for cell and the Looked In range contain numeric, or text values. If the data types do not match up, no match is found.

 

So check your data in the table you are looking up information from, some ID's are text and others are numbers. You want all of them to be text, or all of them numbers. And the cell containing the lookup ID to be of the same data type.

@jgans 

Excel gives you the clues if you know where to look for them.

 

One approach to determining why a lookup function like XLOOKUP is missing is to simplify and create a basic formula to compare contents of two cells:

Patrick2788_0-1700323396546.png

In the first screen capture, =F1=G1 results in FALSE despite the contents appearing to be the same.  In the next screen capture, each cell is evaluated with F9 to show you how Excel sees things. 

@Patrick2788 

 

I am having the exact same issue and I have verified using the =Cell=Cell that they are in fact indentical. This returns True. What else could it be?

What does your formula look like?

@Nabercrombie55 

 

As @Patrick2788  wrote, it behooves you to show us the formulas -- and the data as well.

 

Even better (since cell=cell has different results), attach an Excel file that demonstrates the problem.  Click  on "browse files to attach" at the bottom of the reply applet.

 

That said, I suspect that one or both cells are calculated, and their internal binary values differ infinitesimally.

 

The remedy might be:  be sure that both cells are explicitly rounded to the same precision.

 

The difference might be invisible because Excel formats only up to 15 significant digits.

 

And the equal operator ( "=" ) compares values that are rounded to 15 significant digits internally just for the purpose of the comparison.

 

In contrast, lookup and match functions compare the full binary value, which is not limited 15 significant digits, contrary to most online documentation including MSFT's.

 

Example:

JoeUser2004_0-1726132780123.png