Feb 04 2024 05:13 PM
I have an array with 3 columns and another array with 4 columns. I'm trying to find a formula that will
compare the 3 values in a row in the 1st array, compare it to three values in a row in the 2nd array, find the first result that DOESN'T match an return the 4th value of that row from the 2nd array. (if that makes any sense).
Any help would be VERY appreciated.
Feb 04 2024 06:07 PM
Let's say your first array is in the range A2:C4 and the second array is in the range E2:H4.
In the cell where you want to get the result, enter the following array formula:
=INDEX(H2:H4, MATCH(0, MMULT(--(A2:C4<>E2:G4), TRANSPOSE(COLUMN(A2:C4)^0)), 0))
This formula should works by comparing each row in the first array with the corresponding row in the second array. The MMULT() is used to sum the results of the comparison for each row. then MATCH() is used to find the first row where the sum is not zero (indicating a mismatch).
Feb 04 2024 06:18 PM
Feb 04 2024 06:28 PM
Feb 04 2024 07:17 PM - edited Feb 04 2024 07:50 PM
Solution@Immortalis
it worked for me. I've just slightly revised the formula.
=INDEX(H2:H4, MATCH(TRUE, MMULT(--(A2:C4<>E2:G4), TRANSPOSE(COLUMN(A2:C4)^0))>0, 0))
note: this formula will only return the first mismatched from your arrays. and if you have multiple mismatches, it will need a SMALL function with ROW function as the second argument to the Nth smallest value from your arrays row numbers where there is a mismatch.
formula if multiple mismatches:
=IFERROR(INDEX($H$2:$H$4, SMALL(IF(MMULT(--($A$2:$C$4<>$E$2:$G$4), TRANSPOSE(COLUMN($A$2:$C$4)^0))>0, ROW($A$2:$A$4)-ROW($A$2)+1), ROW(A1))), "")
after pasting that formula (with Ctrl+Shift+Enter) example in cell B9, then copy that cell and paste it in cell B10 and B11
Feb 04 2024 07:33 PM
Feb 04 2024 07:42 PM
Feb 04 2024 09:08 PM
I converted it over and managed to get is to work,
INDEX(AQ137:AQ164, MATCH(TRUE, MMULT(--(BaseInfo!$U$15:BaseInfo!$W$114<>AO137:AQ137), TRANSPOSE(COLUMN(BaseInfo!$U$15:BaseInfo!$W$114)^0))>0, 0))
Thank you VERY much! Would you be able to add something to it though? When it finds the line that doesn't exist, I need it to check that line and make sure the cell in the "U" column is equal to _SectionCalc.
If you could do that, then my issue is completely solved!
Feb 04 2024 09:26 PM
@Immortalis
you can add an additional condition to the formula to check if the cell in the “U” column is equal to _SectionCalc
updated formula:
=INDEX(AQ137:AQ164, MATCH(TRUE,
(MMULT(--(BaseInfo!$U$15:BaseInfo!$W$114<>AO137:AQ137),
TRANSPOSE(COLUMN(BaseInfo!$U$15:BaseInfo!$W$114)^0))>0)*
(BaseInfo!$U$15:BaseInfo!$U$114="_SectionCalc"), 0))
(BaseInfo!$U$15:BaseInfo!$U$114="_SectionCalc") checks if the cell in the “U” column is equal to _SectionCalc. The * operator acts as a logical AND, so both conditions must be true for a row to be considered a match.
As always Ctrl+Shift+Enter after typing the formula.
Feb 04 2024 09:37 PM
Feb 04 2024 09:40 PM
Feb 04 2024 10:21 PM - edited Feb 04 2024 10:21 PM
i thought that was a text value, could you be more specific, what's the range of your _Sectioncalc
Feb 04 2024 10:23 PM
Feb 04 2024 10:26 PM - edited Feb 04 2024 10:31 PM
have you checked it's format? they must be the same. in order to make it work.
there might be an issue with how the dates are being compared. Excel stores dates as numbers, so if the format in _SectionCalc is different from the format of the dates in BaseInfo!$U$15:BaseInfo!$U$114, they might not match even if they represent the same date.
Feb 04 2024 10:47 PM
Feb 04 2024 11:10 PM
Feb 04 2024 11:25 PM
@ere's my sample book.
Feb 05 2024 04:58 PM
So apparently...
INDEX($U$15:$U$114,MATCH($Y$3,$U$15:$U$114,0))=Y3
Works just fine on it's own, but when I incorporate it into your formula it returns #N/A.
Is there anything you can do to solve that?
Thank you.
Feb 05 2024 05:05 PM
@Immortalis
try this:
=IFERROR(INDEX(Baseinfo!$X$15:$X$38, SMALL(IF((MMULT(--($AO$137:$AQ$137<>Baseinfo!$U$15:Baseinfo!$W$38), TRANSPOSE(COLUMN($AO$137:$AQ$137)^0))>0)*(Baseinfo!$U$15:Baseinfo!$U$38=_SectionCalc), ROW(Baseinfo!$U$15:Baseinfo!$U$38)-ROW(Baseinfo!$U$15)+1), ROW(A1))), "")
I attached your sample file with the formula
Feb 04 2024 07:17 PM - edited Feb 04 2024 07:50 PM
Solution@Immortalis
it worked for me. I've just slightly revised the formula.
=INDEX(H2:H4, MATCH(TRUE, MMULT(--(A2:C4<>E2:G4), TRANSPOSE(COLUMN(A2:C4)^0))>0, 0))
note: this formula will only return the first mismatched from your arrays. and if you have multiple mismatches, it will need a SMALL function with ROW function as the second argument to the Nth smallest value from your arrays row numbers where there is a mismatch.
formula if multiple mismatches:
=IFERROR(INDEX($H$2:$H$4, SMALL(IF(MMULT(--($A$2:$C$4<>$E$2:$G$4), TRANSPOSE(COLUMN($A$2:$C$4)^0))>0, ROW($A$2:$A$4)-ROW($A$2)+1), ROW(A1))), "")
after pasting that formula (with Ctrl+Shift+Enter) example in cell B9, then copy that cell and paste it in cell B10 and B11