Nested IF with XLOOKUP formula

janema

Board Regular
Joined
Nov 28, 2022
Messages
143
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2011
  5. 2010
Platform
  1. Windows
  2. Mobile
I am trying to get this formula to return BLANK if cell AS2 is blank, and if the first XLOOKUP is Blank or no data, to use the second XLOOKUP, otherwise keep the first XLOOKUP. For some reason, it is only working with the first XLOOKUP. Can someone please help me figure out why the formula isn't working? Thank you so much in advance! ❤️

The formula is currently written as follow and shown below:

=IF(AS2="","",IF(XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P)="",XLOOKUP(AS2,'All US 4.2024'!L:L,'All US 4.2024'!P:P),XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P)))

1722279166484.png
 
Start with making this change:
Rich (BB code):
=IF(AS2="","",IF(XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P,"")="",XLOOKUP(AS2,'All US 4.2024'!L:L,'All US 4.2024'!P:P),XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P)))

Fluff's point if what do you want to do if it exists in LS 4.2024 but the value is 0.
Since its likely that the dashes there are 0

1722329343254.png


Also what version of Excel do you need the solution to work on, if you only need it to work on 365 or 2021 we can use the Let function to simplify it.
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Start with making this change:
Rich (BB code):
=IF(AS2="","",IF(XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P,"")="",XLOOKUP(AS2,'All US 4.2024'!L:L,'All US 4.2024'!P:P),XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P)))

Fluff's point if what do you want to do if it exists in LS 4.2024 but the value is 0.
Since its likely that the dashes there are 0

View attachment 114709

Also what version of Excel do you need the solution to work on, if you only need it to work on 365 or 2021 we can use the Let function to simplify it.

Ohhhh, I am so sorry! If there is a value, but it is 0, then I also want it to take from the other sheet the "All US 4.2024."
 
Upvote 0
Start with making this change:
Rich (BB code):
=IF(AS2="","",IF(XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P,"")="",XLOOKUP(AS2,'All US 4.2024'!L:L,'All US 4.2024'!P:P),XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P)))

Fluff's point if what do you want to do if it exists in LS 4.2024 but the value is 0.
Since its likely that the dashes there are 0

View attachment 114709

Also what version of Excel do you need the solution to work on, if you only need it to work on 365 or 2021 we can use the Let function to simplify it.

Forgot to answer your last question. It is on 365.
 
Upvote 0
Thanks for the responses, give this a try.
You will need to copy it directly into the formula box on row 2
Excel Formula:
=LET(getLS,XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P,0),
     IF(AS2="",
        "",
        IF(getLS=0,
           XLOOKUP(AS2,'All US 4.2024'!L:L,'All US 4.2024'!P:P),
           getLS)))

Using Let will save performing the LS lookup twice where it needs to.
In terms of your original formula the key change is in red below:
Rich (BB code):
=IF(AS2="","",IF(XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P,0)=0,XLOOKUP(AS2,'All US 4.2024'!L:L,'All US 4.2024'!P:P),XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P)))
 
Last edited:
Upvote 0
Solution
Thanks for the responses, give this a try.
You will need to copy it directly into the formula box on row 2
Excel Formula:
=LET(getLS,XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P,0),
     IF(AS2="",
        "",
        IF(getLS=0,
           XLOOKUP(AS2,'All US 4.2024'!L:L,'All US 4.2024'!P:P),
           getLS)))

Using Let will save performing the LS lookup twice where it needs to.
In terms of your original formula the key change is in red below:
Rich (BB code):
=IF(AS2="","",IF(XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P,0)=0,XLOOKUP(AS2,'All US 4.2024'!L:L,'All US 4.2024'!P:P),XLOOKUP(AS2,'LS 4.2024'!L:L,'LS 4.2024'!P:P)))

Thank you so much!! ❤️
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,120
Members
453,021
Latest member
Justyna P

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