在Google Spreadsheets中,我需要在具有多个条件的范围内使用COUNTIF函数。所以在下表中我需要有类似= COUNTIF(B:B,“Mammal”或“Bird”)的东西,并返回值4。
A |B
-------------------
Animal | Type
-------------------
Dog | Mammal
Cat | Mammal
Lizard | Reptile
Snake | Reptile
Alligator | Reptile
Dove | Bird
Chicken | Bird
我尝试过很多不同的方法但没有运气。任何帮助表示赞赏 - 谢谢。
一种选择:
=COUNTIF(B:B; "Mammal") + COUNTIF(B:B; "Bird")
根据文件:
笔记
COUNTIF 只能使用单一标准执行条件计数。
要使用多个条件,请使用 COUNTIFS 或数据库功能
DCOUNT 要么 DCOUNTA。
COUNTIFS
:此功能仅适用于 新的Google表格。
例:
=DCOUNTA(B:B; 2; {"Type"; "Mammal"; "Bird"})
一种选择:
=COUNTIF(B:B; "Mammal") + COUNTIF(B:B; "Bird")
根据文件:
笔记
COUNTIF 只能使用单一标准执行条件计数。
要使用多个条件,请使用 COUNTIFS 或数据库功能
DCOUNT 要么 DCOUNTA。
COUNTIFS
:此功能仅适用于 新的Google表格。
例:
=DCOUNTA(B:B; 2; {"Type"; "Mammal"; "Bird"})
您还可以在SUM(COUNTIFS())构造周围使用ArrayFormula:
=ArrayFormula(SUM(COUNTIF(B:B,{"Mammal", "Bird"}))
来源:Google Docs产品论坛