XLOOKUP - Stopping when one condition is met

Ozzy23

New Member
Joined
Dec 21, 2023
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Hi All,


I posted yesterday in relation to a XLOOKLUP query I had. Thank you that got resolved with the forums help :) Another day today and I have another complex problem so any support would be appreciated as I'm learning too.


  1. I have a number of ID values (Will call these X) on worksheet 1. These X values correspond to another set of IDs (Will call these Y) on worksheet 2 that have status associated with them FAIL, BLOCKED, etc..
  2. The X values can appear more than once so there are different Y IDs and status that correspond with each X value
  3. I need the condition to stop once a certain status is met, so for IDX-1 if the status is failed at all then the remaining status does not matter no matter how many times the value appears.
For example:

ID X VALUE (WORKSHEET 1)CORRESPONDING Y VALUE (WORKSHEET 2)CORRESPONDING STATUS (WORKSHEET 2)
IDX-1IDY-11FAIL
IDX-1IDY-33PASS
IDX-1IDY-44BLOCKED
IDX-2IDY-100PASS

My unsuccessful method

  1. I was first trying to do a XLOOKUP to find the corresponding values of Y since this is on another worksheet and return the status. Since the values of X can be found in 4 columns in the lookup array on worksheet 2 I was concatenating using the & for each column.
  2. I was then trying to use IF function to try and stop the the return results once it had found the first fail
=XLOOKUP(A2,'Worksheet2'!F$2:F$2515&'Worksheet2'!G$2:G$2515&'Worksheet2'!H$2:H$2515&'Worksheet2'!I$2:I$2515,'Worksheet2'!R$2:R$2515)
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try

Here's the corrected formula:

=IFERROR(INDEX('Worksheet2'!$R$2:$R$2515, MATCH(A2, 'Worksheet2'!$F$2:$F$2515 & 'Worksheet2'!$G$2:$G$2515 & 'Worksheet2'!$H$2:$H$2515 & 'Worksheet2'!$I$2:$I$2515, 0)), "")

Explanation:

  • The MATCH function is used to find the first occurrence of the ID X in the concatenated range of ID Y values on Worksheet 2.
  • The CONCATENATE operator (&) is used to combine the values from columns F, G, H, and I on Worksheet 2 into a single string.
  • The INDEX function retrieves the corresponding status from column R on Worksheet 2.
  • The IFERROR function is used to handle cases where there is no match, returning an empty string if there is an error.
Make sure to adjust the ranges ('Worksheet2'!$F$2:$F$2515, 'Worksheet2'!$G$2:$G$2515, 'Worksheet2'!$H$2:$H$2515, 'Worksheet2'!$I$2:$I$2515, 'Worksheet2'!$R$2:$R$2515) to match the actual range of data on Worksheet 2.
 
Upvote 0

Forum statistics

Threads
1,224,821
Messages
6,181,163
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