1

How do I write an (array) formula to extract distinct values that do not occur in a second list?

For example

Source list

 - Apple
 - Apple
 - Banana
 - Carrot
 - Carrot
 - Blueberry

Exclusion list

- Carrot

Expected output

- Apple
- Banana
- Blueberry
1
  • If you have Excel 2019 or higher, maybe you could try something like =CONCAT(SI($A$1:$A$5<>$C$1;$A$1:$A$5)) but entered as ArrayFormula, and where A1:A5 would be your source list and C1 would be Exclusion list. That would be only a part, still need to remove duplicates. Have you tried something? Commented Mar 12, 2020 at 11:55

3 Answers 3

2

You can use this formula described at [C2:C4] to get your distinct value:

=IFERROR(INDEX($A$2:$A$7,MATCH(0,COUNTIF($C$1:C1,$A$2:$A$7)+COUNTIF($B$2,$A$2:$A$7),0),0),"")

or with excel365 described at [E2:E4]:

=UNIQUE(FILTER(A2:A7,A2:A7<>B2))

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

That did the trick! Thanks. Now to see if my laptop can handle this with +/-20k rows in each list ;)
Hi, Nice to hear that!
1

If you can use Excel 365 or the Excel web app, then try:

=SORT(UNIQUE(IF(A1:A5<>"Carrot",A1:A5,"")),,-1)

enter image description here

(this is a spill-down, not a standard array formula)

1 Comment

Thanks for the reply, unfortunately my 365 does not seem to have SORT or UNIQUE, so that's a no-go for me.
0

Formula in D2, copied down :

=IFERROR(INDEX(A$2:A$7,AGGREGATE(15,6,ROW(A$2:A$7)-ROW(A$2)+1/(A$2:A$7<>C$2)/(COUNTIF(D$1:D1,A$2:A$7)=0),1)),"")

enter image description here

1 Comment

Very nice. That seems to work only if the Exclusion list has a single value though. It does not accept a range of values (for example C$2:C$3) as a substitute for C$2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.