Google Spreadsheets:我如何将COUNTIF与OR结合 [英] Google Spreadsheets: How do I combine COUNTIF with OR
问题描述
在Google Spreadsheets中,我需要在具有多个条件的范围上使用COUNTIF函数。所以在下面的表格中,我需要像= COUNTIF(B:B,Mammal或Bird),并返回值为4的值。
A | B
-------------------
Animal |输入
-------------------
Dog |哺乳动物
Cat |哺乳动物
Lizard |爬行动物
Snake |爬行动物
Alligator | Reptile
Dove |鸟
鸡| Bird
我尝试了很多不同的方法,但都没有运气。
一个选项:
= COUNTIF(B:B;Mammal)+ COUNTIF(B:B;Bird)
根据文档:
注释
COUNTIF 只能使用单一条件执行条件计数。
要使用多个条件,请使用 COUNTIFS 或数据库函数
帐户或 DCOUNT 。
COUNTIFS
:此功能仅适用于新版Google表格
= DCOUNTA(B:B; 2; {Type;Mammal;Bird})
In Google Spreadsheets, I need to use the COUNTIF function on a range with multiple criteria. So in the table below I would need to have something like =COUNTIF(B:B,"Mammal"or"Bird") and return a value of 4.
A |B
-------------------
Animal | Type
-------------------
Dog | Mammal
Cat | Mammal
Lizard | Reptile
Snake | Reptile
Alligator | Reptile
Dove | Bird
Chicken | Bird
I've tried a lot of different approaches with no luck. Any help appreciated - thanks.
One option:
=COUNTIF(B:B; "Mammal") + COUNTIF(B:B; "Bird")
According to the documentation:
Notes
COUNTIF can only perform conditional counts with a single criterion. To use multiple criteria, use COUNTIFS or the database functions DCOUNT or DCOUNTA.
COUNTIFS
: This function is only available in the new Google Sheets.
Example:
=DCOUNTA(B:B; 2; {"Type"; "Mammal"; "Bird"})
这篇关于Google Spreadsheets:我如何将COUNTIF与OR结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!