Google Spreadsheet multiple column filter using OR

后端 未结 1 1935
野趣味
野趣味 2021-02-05 19:16

I have a Google Spreadsheet with 3 columns that are either blank or have a value. I want to get the count of the number of rows that has A and either B or C populated. If I we

相关标签:
1条回答
  • 2021-02-05 20:18

    The formula below should do what you are after:

    =ROWS(FILTER(A2:A, NOT(ISBLANK(A2:A)), NOT(ISBLANK(B2:B))+NOT(ISBLANK(C2:C)) ))
    

    And to explain:

    • ROWS counts the rows of the argument (filtered, in our case)
    • FILTER returns the rows of arg1 (A2:A) that all subsequent arguments match
    • The + (addition) symbol combines two predicates with a logical OR

    Finally, if you are not using header columns you can change the references from A2:A to A:A

    Alternatively, you can use the QUERY function:

    (Broken into multiple lines for readability)

    =ROWS(QUERY(A2:C, 
        "SELECT A WHERE A IS NOT NULL AND (B IS NOT NULL OR C IS NOT NULL)"))
    

    For more information on the syntax of the queries, see the Visualization API Query Language Reference and specifically the Language Reference

    0 讨论(0)
提交回复
热议问题