regex - 如何将COUNTIF与OR结合

标签 regex google-sheets countif google-sheets-formula array-formulas

在Google Spreadsheets中,我需要在具有多个条件的范围内使用COUNTIF函数。因此,在下表中,我需要使用=COUNTIF(B:B,"Mammal"or"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")

根据文档:

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 :此功能仅在new Google Sheets中可用。

例:
=DCOUNTA(B:B; 2; {"Type"; "Mammal"; "Bird"})

关于regex - 如何将COUNTIF与OR结合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21419578/

相关文章:

regex - Google Sheets - 将 split 与 regexextract/regexreplace 相结合

excel - Excel中的Countifs,以名称列表为条件

excel - 如何在 Countifs 函数的 criteria_range 中做一些数学运算(在 Countif 中使用 OR)

regex - Sublime Text2如何用参数替换?

javascript - Express.js : regex in route

google-apps-script - 日期字段的 Google App Script 事件值类型不同于 e.value 和 e.range.getValue()

pdf - Google Sheets Export to PDF Script - 为什么要导出隐藏的行?

c++ - gsl_vector 有 count_if 函数吗? C/C++

java - 如何匹配String中的特定字符n-m次

regex - 如何匹配以相同字符开头和结尾但具有奇数个字母的字符串?