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 were writing a SQL query it would be
select count(*)
from Table
where A is not null and (B is not null or C is not null)
But I can’t for the life of me figure out how to get this in a Google Spreadsheet
The formula below should do what you are after:
And to explain:
ROWScounts the rows of the argument (filtered, in our case)FILTERreturns the rows of arg1 (A2:A) that all subsequent arguments match+(addition) symbol combines two predicates with a logicalORFinally, if you are not using header columns you can change the references from
A2:AtoA:AAlternatively, you can use the
QUERYfunction:(Broken into multiple lines for readability)
For more information on the syntax of the queries, see the Visualization API Query Language Reference and specifically the Language Reference