如何将 COUNTIF 与 OR 结合使用 [英] How do I combine COUNTIF with OR

查看:239
本文介绍了如何将 COUNTIF 与 OR 结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Google 电子表格中,我需要在具有多个条件的范围内使用 COUNTIF 函数.所以在下表中,我需要像 =COUNTIF(B:B,"Mammal"or"Bird") 之类的东西,并返回 4 的值.

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.

推荐答案

一个选项:

=COUNTIF(B:B; "Mammal") + COUNTIF(B:B; "Bird")

根据文档:

注意事项

COUNTIF 只能使用单一条件执行条件计数.要使用多个条件,请使用 COUNTIFS 或数据库函数DCOUNTDCOUNTA.

COUNTIF can only perform conditional counts with a single criterion. To use multiple criteria, use COUNTIFS or the database functions DCOUNT or DCOUNTA.

COUNTIFS:此功能仅在 新的 Google 表格.

示例:

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

这篇关于如何将 COUNTIF 与 OR 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆