xlookup - if cannot find criteria A then search for criteria B help

shellwig

New Member
Joined
Dec 22, 2015
Messages
38
Office Version
  1. 365
Platform
  1. Windows
Thank you in advance for your guidance. I'm not sure if I'm heading down the correct path but I'm trying to search for criteria A, if not found then I want to search for criteria B.
I'm using an concatenated xlookup function.

1726683247380.png
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How about:

VBA Code:
=XLOOKUP(B7&E1,A1:A5&B1:B5,C1:C5,XLOOKUP(B7&E2,A1:A5&B1:B5,C1:C5))
 
Upvote 0
Solution
Thank you for your help! The above solution works. I was able to resolve via another formula. see below for both solutions.

1726684961020.png
 
Upvote 0
@shellwig
=XLOOKUP(1,(A1:A5&B1:B5=B7&E1)+(A1:A5&B1:B5=B7&E2),C1:C5) will still pick row 2 if you change E1 to 12/31/2022, because it will find two matches but pick the first match from C1:C5, and it will be 12/31/2023 since it is above 12/31/2022.
Also, I know that it doesn't make sense setting E1 and E2 as equal in this structure but the formula will also fail in that scenario: 1+1 = 2.

However, the other formula by @ExcelToDAX returns the correct value in all cases.

So, I believe the working formula is provided by @ExcelDAX and I am switching the marked solution post. If you think otherwise and I am missing something then please let me know.
 
Upvote 0

Forum statistics

Threads
1,224,045
Messages
6,176,065
Members
452,703
Latest member
kinnowboxes

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