Google-sheets – way to filter columns in Google Spreadsheets

google sheets

Is there a way to filter columns in Google Spreadsheets:

  • Column (A) contains new data
  • Column (B) contains filter data, i.e. cells with text that should not be included in column C
  • Column (C) is the outcome, i.e. column A minus all the cell data in column B

If I cannot filter by column, is there another way to reach a similar result?

Best Answer

Solution

Place this formula in cell C2:

=ARRAYFORMULA(SORT(UNIQUE(IF(ISNA(MATCH(A2:A,B2:B,0)),A2:A,""))))

What you want is the set difference. This formula will give you all the unique values of column A that do not appear in column B.

Details

MATCH(search_criterion, lookup_array, [match_type]) checks if an element is found in the given array. In this case it checks the element from column A in the entire array of B. If it is not found it returns NA.

IF(ISNA(...), A2:A, "") returns the contents of cell from column A if it was not matched, or an empty string if it was.

SORT(UNIQUE(...)) is optional, but will filter the results in alphabetical order and remove any duplicates which is probably what you want.

Finally ARRAYFORMULA returns the result as an array so that it populates the entire C column.

More information: