Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google spreadsheet get complements

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}
like image 791
KaZyKa Avatar asked May 21 '26 00:05

KaZyKa


2 Answers

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)
like image 66
Max Makhrov Avatar answered May 24 '26 12:05

Max Makhrov


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

=arrayformula(if(B2:B=A2:A,,A2:A))
like image 44
Aurielle Perlmann Avatar answered May 24 '26 12:05

Aurielle Perlmann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!