Formatting inconsistency breaks XLOOKUP - any formula-way to fix it?

excelos

Well-known Member
Joined
Sep 25, 2011
Messages
591
Office Version
  1. 365
Platform
  1. Windows
Hello!

Often there is a mismatch in formatting so that XLOOKUP does not pick up looked-up values if not stored in the same format.

Is there a formula way to overcome this?

I was thinking to wrap the values in N() or TEXT() but I don't think these work.

Any idea?

Thanks!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
XLOOKUP does not care about display format. I'm not sure I follow your terminology, because values are not stored in a format, they are displayed in a format.

There will be a difference if a value is text vs. numeric. For example, if you have the number 123 vs. the text string "123" XLOOKUP will not see those as a match, but that is data type, not display format.

Can you give a specific, concrete example where XLOOKUP does not work the way you are expecting?

Here is my example:

$scratch.xlsm
ABCDE
1Lookup table
2NumbersTarget ValuesSource value (Numbers)Source value (Text)
3123A456456
4456B
5789CXLOOKUP seeking a numberXLOOKUP seeking text
6B#N/A
Sheet10
Cell Formulas
RangeFormula
D6:E6D6=XLOOKUP(D3,$A$3:$A$5,$B$3:$B$5)
 
Upvote 0
Thanks!

I am talking about both lookup values and lookup array to be numbers stored as numbers.
For some reason XLOOKUP did not recognise them until I converted both into 'stored as text'!
 
Upvote 0
Ideally you want to clean up your data, as @6StringJazzer pointed out it is inconsistencies in the data that is the issue ie text on one side and numeric on the other side.

In MS 365 you can cheat and force it all to text which should overcome the issue without actually fixing the underlying data problem.
eg Using Jeff's example
Rich (BB code):
=XLOOKUP(TRIM(D3),TRIM($A$3:$A$5),$B$3:$B$5)
There are other ways of converting it to Text but I find Trim to be nice and clear and covers up some other sins at the same time.
 
Upvote 0
XLOOKUP did not recognise them until I converted both into 'stored as text'!
I am guessing that they were already text in one place. How were the numbers entered into your sheet? I have seen many cases where data is imported from or generated by another application, and what looks like numbers is actually text once it gets into Excel. You can use the ISTEXT function to diagnose this.
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,578
Members
449,174
Latest member
chandan4057

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top