Google spreadsheet get complements

1k Views Asked by At

Link here to spreadsheet

As the title says, how can I end up with cells that don't match in value, the difference/complement (set theory)?

I would prefer it with only FUNCTIONS and no script.

{1,2,3,4}\{1,3} = {2, 4}

or with letters

{a,b,c,d}\{a,c} = {b, d}

or with with space.

{xyz zyx, abc cba, qwe ewq}\{xyz zyx, qwe ewq} = {abc cba}
2

There are 2 best solutions below

0
On BEST ANSWER

Having two arrays:

Array1  Array2
  1       1
  2       b
  b 
  4 
  c 

you can get resulting array:

Result
  2
  4
  c

Try this formula:

=FILTER(A2:A6,ROUND(MMULT(ArrayFormula(--(A2:A6<>TRANSPOSE(B2:B4))),TRANSPOSE(SPLIT(REPT(1/ROWS(B2:B4)&"/",Rows(B2:B4)),"/"))),5)=1)

May be too complex for this task, could somebody edit it? Please, look at sample sheet


Edit

I've found more simple way to do this, using Regular Expressions:

=FILTER(A2:A6,REGEXMATCH(ARRAYFORMULA("'"&A2:A6),JOIN("|",B2:B3))=false)
1
On

You can add one single formula at the top of your result column like this :

=arrayformula(if(B2:B=A2:A,,A2:A))