Filter a range by array

前端 未结 2 759
醉话见心
醉话见心 2020-12-14 02:14

I have a Google Spreadsheet containing the teams of the UEFA EURO 2012, and their scores:

Team     Points  Goals scored
------   ------  ------------
Germany         


        
2条回答
  •  抹茶落季
    2020-12-14 03:17

    For answer-seekers who stumble onto this thread as I did, see this Google product forum page, where both Yogi and ahab present solutions to the question of how to filter a range of data by another range of data.

    If A3:C contains the range of UEFA EURO 2012 data to be filtered, and D3:D contains the list of teams by which to filter, then E3 ...

    =FILTER(A3:C, MATCH(A3:A, D3:D,0))
    

    or

    =FILTER(A3:C, COUNTIF(D3:D, A3:A))
    

    Conversely, if you'd like to filter by teams not listed in D3:D, then E3...

    =FILTER(A3:C, ISNA(MATCH(A3:A, D3:D,0)))
    

    or

    =FILTER(A3:C, NOT(COUNTIF(D3:D, A3:A)))
    

    Here's an example spreadsheet I've made to demonstrate these functions' effectiveness.

提交回复
热议问题