Extract difference between 2 strings with ArrayFormula in Google Sheets

39 views Asked by At

I have a list of initial IDs and a list of resulting IDs in Google Sheets - I'm looking to have the third "Leftover IDs" column compare the first two columns and return the difference in IDs.

Initial IDs Resulting IDs Leftover IDs
NOS202,NOS224 NOS202,NOS224
NOS202,NOS224,NOS227,NOS231,NOS243,NOS318 NOS202,NOS227,NOS231,NOS243 NOS224, NOS318
NOS202,NOS224 NOS202,NOS224

The formula I have works, but I can't get it to automatically apply to a newly added entry. The error I'm getting with the below formula is "FILTER range must be a single row or a single column"

=ARRAYFORMULA(IF(A2:A="",,IF(EXACT(A2:A,B2:B), "", JOIN(", ", FILTER(SPLIT(A2:A, ", "), NOT(COUNTIF(SPLIT(B2:B, ", "), SPLIT(A2:A, ", "))))))))

Please help! I've tried everything.

1

There are 1 answers

0
rockinfreakshow On

You may try:

=byrow(A2:B,lambda(Σ,if(counta(Σ)=0,,join(", ",unique(split(join(",",Σ),","),1,1)))))

enter image description here