If statement based on xlookup or some lookup that return values from a column based on header values

sirmixalot

New Member
Joined
Jan 15, 2016
Messages
7
Hi guys,

As part of my world domination scheme, I am trying to figure out how to return a value from the first table rendering below (row values) based on the column headers in the same table. I use the Loc1/Loc2/Loc3 values in column 1 of table 2 to return a "yes" or "no" from table 1.

I tried @XLookup and I feel like that returns the right answer but for some reason, it does not fit well within an "IF" statement and always gives me false even though I mark it as "If(@XLOOKUP(formula here with exact match))="Yes",1,2) - it always returns 2

Loc1Loc2Loc3Loc4Loc5
YesYesYesYesNo
YesYesYesNoNo
YesYesYesNoNo
YesYesYesYesNo
YesYesYesYesNo
YesYesYesYesNo
YesYesYesYesYes
YesYesYesYesYes
YesYesYesYesYes


locationplanplan[id]
Loc1bmLOc1-bm
Loc2bmLoc2-bm
Loc3bmLoc3-bm
Loc4bmLoc4-bm
Loc5bmLoc5-bm
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Thanks for the comment @CA_Punit !

I redid the exercise as follows in a blank sheet and got the answer i was looking for.

For Context,

Sheet 1 is the first table as shown and Sheet 2 is the second table. Here is what I try

if I try the following:
=(@XLOOKUP(A19,Sheet1!$O$5:$S$5,Sheet1!$O$6:$S$26,"not found",0)), I get "Yes"

However, if I try the following:

=@IF(XLOOKUP(A19,Sheet1!$O$5:$S$5,Sheet1!$O$6:$S$26,"not found",0)="Yes",1,2)

I was getting 2 in the sheet I was working in but in a blank sheet, I am getting 1 which informs me there was something wrong with my sheet.
 
Upvote 0
Not sure what you are trying to do, or if you realise this, but your formula is effectively only looking at row 6 ie
=IF(XLOOKUP(A19,Sheet1!$O$5:$S$5,Sheet1!$O$6:$S$6,"not found",0)="Yes",1,2)
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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