Please help - XLOOKUP formula works on 1 value only

turner369

New Member
Joined
Aug 16, 2021
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

I'm doing a spreadsheet where I'm using XLOOKUP to retrieve certain data with multiple criteria. By inputting the name in cell A5, cells B5 to E5 will retrieve the data from the spreadsheet below.

My formula is this

For Cell B5 =XLOOKUP(B4,G10:G37,XLOOKUP(A5,A10:A37,H10:H37))
For Cell C5 =XLOOKUP(C4,G10:G37,XLOOKUP(A5,A10:A37,H10:H37))
For Cell D5 =XLOOKUP(D4,G10:G37,XLOOKUP(A5,A10:A37,I10:I37))
For Cell E5 =XLOOKUP(E4,G10:G37,XLOOKUP(A5,A10:A37,I10:I37))

Now this is the most perplexing issue, the formula only works for T-shirts as seen below

1629129405216.png


However, when i sort by Category (Column G), the T-shirt formulas stop working and the Pants formula starts working

1629129553032.png


Tried sorting the other columns and there were no issues. Cell formats are also all the same

I have absolutely no clue why this is happening. Why does XLOOKUP work/not work when it is the exact same formula with only the lookup_value changed?

Please help!!

FYI i am using Microsoft Office Professional Plus 2019 with the ExcelDna.XFunctions Add-in for XLOOKUP function
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi & welcome to MrExcel.
How about
Excel Formula:
=INDEX(H10:H37,MATCH(A5&"|"&B4,A10:A37&"|"&G10:G37,0))
This will need to be confirmed with Ctrl Shift Enter, rather than just enter.
 
Upvote 0
Solution
Hi & welcome to MrExcel.
How about
Excel Formula:
=INDEX(H10:H37,MATCH(A5&"|"&B4,A10:A37&"|"&G10:G37,0))
This will need to be confirmed with Ctrl Shift Enter, rather than just enter.
Yes, this does work!! thank you so much!! but would you happen to know why my xXLOOKUP formula didn't work? I'm still quite perplexed on why the order of the category decides whether the formula works or not
 
Upvote 0
Assuming that the add-in works in the same way as a normal Xlookup, your formula does not make much sense.
With this
Rich (BB code):
=XLOOKUP(C4,G10:G37,XLOOKUP(A5,A10:A37,H10:H37))
the part in red will return the first cell that matches A5, which in your example is A10. That will then feed into the outer xlookup which becomes
Rich (BB code):
=XLOOKUP(C4,G10:G37,H10))
so unless C4 is found in row 10 it will never work.
 
Upvote 0
Assuming that the add-in works in the same way as a normal Xlookup, your formula does not make much sense.
With this
Rich (BB code):
=XLOOKUP(C4,G10:G37,XLOOKUP(A5,A10:A37,H10:H37))
the part in red will return the first cell that matches A5, which in your example is A10. That will then feed into the outer xlookup which becomes
Rich (BB code):
=XLOOKUP(C4,G10:G37,H10))
so unless C4 is found in row 10 it will never work.
thank you for the answer! guess i need some brushing up on my formulation
 
Upvote 0
thank you for the answer! guess i need some brushing up on my formulation

Assuming the Add-In works exactly the same as the 365 version.

Then this is how your xlookups should look.

20210818 XLookup AddIn.xlsx
ABCDEFGHIJ
1
2
3QuantitySize
4NameT-ShirtsPantsT-ShirtsPants
5Jose31L32
6
7
8
9NameCodeNumberDate JoinedDate ResignedTitleCategoryQuantitySize
10JoseT-Shirts3L
11JosePants132
12AinT-Shirts4S
13AinPants0
14
Sheet1
Cell Formulas
RangeFormula
B5:C5B5=XLOOKUP(1,($G$10:$G$37=B$4)*($A$10:$A$37=$A5),$H$10:$H$37)
D5:E5D5=XLOOKUP(1,($G$10:$G$37=D$4)*($A$10:$A$37=$A5),$I$10:$I$37)
 
Upvote 0
Assuming the Add-In works exactly the same as the 365 version.

Then this is how your xlookups should look.

20210818 XLookup AddIn.xlsx
ABCDEFGHIJ
1
2
3QuantitySize
4NameT-ShirtsPantsT-ShirtsPants
5Jose31L32
6
7
8
9NameCodeNumberDate JoinedDate ResignedTitleCategoryQuantitySize
10JoseT-Shirts3L
11JosePants132
12AinT-Shirts4S
13AinPants0
14
Sheet1
Cell Formulas
RangeFormula
B5:C5B5=XLOOKUP(1,($G$10:$G$37=B$4)*($A$10:$A$37=$A5),$H$10:$H$37)
D5:E5D5=XLOOKUP(1,($G$10:$G$37=D$4)*($A$10:$A$37=$A5),$I$10:$I$37)
Hey Alex, thanks for the tip. Can I ask why is the lookup value 1?
 
Upvote 0
Because the next set of parameters are
(array=value)*(array=value)
These return sets of trues and falses.
These when multiplied together turn into 1s and 0s.
Let me know I haven't explained it well.
 
Upvote 0

Forum statistics

Threads
1,215,332
Messages
6,124,313
Members
449,153
Latest member
JazzSingerNL

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