使用 OR 的 Google 电子表格多列过滤器
我有一个 Google 电子表格,其中有 3 列,这些列要么是空白的,要么是有值的。我想获取填充了 A 和 B 或 C 的行数。如果我正在编写一个 SQL 查询,那么它会是
select count(*)
from Table
where A is not null and (B is not null or C is not null)
但我一生都无法弄清楚如何在 Google 电子表格中获取它
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面的公式应该可以满足您的要求:
并解释一下:
ROWS
计算参数的行数(在我们的例子中已过滤)FILTER
返回 arg1 的行 (A2:A
) 所有后续参数都匹配+
(加法)符号将两个谓词与逻辑OR
组合起来最后,如果您不使用标题列,则可以将引用从
A2:A
更改为A:A
或者,您可以使用
QUERY
函数:(为了便于阅读,分成多行)
了解更多有关查询语法的信息,请参阅可视化 API 查询语言参考特别是语言参考
The formula below should do what you are after:
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+
(addition) symbol combines two predicates with a logicalOR
Finally, if you are not using header columns you can change the references from
A2:A
toA:A
Alternatively, you can use the
QUERY
function:(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
如果 SUMPRODUCT() 只有一个参数,则其工作方式与 SUM(ARRAYFORMULA(N( ))) 相同
if there is only one argument for SUMPRODUCT() it works just as SUM(ARRAYFORMULA(N( )))