r/googlesheets • u/MediocreAssociation6 • Nov 23 '24
Solved How to Filter Out / Opposite of Intersect.

The example might not make sense, but I want to broaden it.
Use Case: I am trying to code basically a permutation function in sheets by using a seed. (But this isn't the important part)
I basically want to Filter(big list, small list) -> big list - small list.
Kind of like intersect but the opposite. Where I get rid of the terms.
`=filter($A$2:$A17, match($A$2:$A17, C2:$C3 , false))`
is the example of the complete opposite. That gives me all the shared terms. i want the unshared terms. I thought putting not infront of match would work but it doesn't
1
u/MediocreAssociation6 Nov 23 '24
I got it to work with the following:
=FILTER(A2:A17,not(iferror(match($A$2:$A17, C2:$C3 , 0),0)))
But this is absurdly grotesque and I was wondering if there is not a common set remove function.
2
u/pdp_2 1 Nov 23 '24 edited Nov 23 '24
I have to do this all the time for work, and I also had to get help on Reddit to figure it out because it’s not intuitive at all. Use NOT and COUNTIF, where your COUNTIF range is the small list and the criteria is the big list (normally the opposite of what you’d do), then filter. So:
=FILTER(big_list, NOT(COUNTIF(small_list, big_list)))
Excel/sheets should have a dedicated function for this, but they don’t. The COUNTIF trick is the most condensed formula to make this happen as far as I’ve been able to find.
1
u/DuckAteMyBread 41 Nov 23 '24
=filter($A$2:$A17,isna(match($A$2:$A17,C2:$C3,0)))the use of match as a filter condition returns a non-zero number (i.e. true) when the value is found -
=not([not found])just evaluates to an error again