简体   繁体   English

COUNTIF有多个标准和列表

[英]COUNTIF with multiple criteria and list

I need to count the number of cells in which 'CRITERIA 1' is satisfied, 'CRITERIA 2' is satisfied and 'CRITERIA 3' falls within the set of values contained in column E. 我需要计算满足'标准1'的单元格数,'标准2'满足,'标准3'属于列E中包含的值集合。

I am currently using the following formula: 我目前正在使用以下公式:

=SUM(COUNTIFS(A2:A11,"TRUE",B2:B11,"TRUE",C2:C11,{"2","4","6","9","10"}))

But in my real table, the list of data within 'CRITERIA 3' is longer and more complicated and I would prefer to reference the cells in column E rather than the specific data, ie something like: 但在我的真实表格中,'CRITERIA 3'中的数据列表更长更复杂,我更愿意引用E列中的单元格而不是特定数据,例如:

=SUM(COUNTIFS(A2:A11,"TRUE",B2:B11,"TRUE",C2:C11,{"E2:E6"}))

Please note that the data contained in this example is different to the data in my real table. 请注意,此示例中包含的数据与实际表中的数据不同。 The real table is considerably longer and more complex than this table. 真正的表比这个表长得多,也更复杂。

Any suggestions? 有什么建议?

例

Decided to put my comment as an answer so I can show a picture that it works: 决定将我的评论作为答案,以便我可以展示它的作用:

You are close. 你很亲密 The Range is an array so no need for the {""} wrapper Range是一个数组,因此不需要{""}包装器

Just use: 只需使用:

=SUM(COUNTIFS(A2:A11,"TRUE",B2:B11,"TRUE",C2:C11,E2:E6))

This is an array formula and must be confirmed with Ctrl-Shift-Enter. 这是一个数组公式,必须使用Ctrl-Shift-Enter确认。

在此输入图像描述

你可以尝试SUMPRODUCT

=SUMPRODUCT((A2:A11="TRUE")*(B2:B11="TRUE")*(E2:E6="2"))

Using COUNTIFS the only way I'd know of to check a value is in a list is to create a dummy column that has that check and make that column Criteria3 instead of the actual value. 使用COUNTIFS ,我知道在列表中检查值的唯一方法是创建一个具有该检查的虚拟列,并使该列为Criteria3而不是实际值。

Going from your example, you'd drop in the following formula in Column D (set text to white so the workbook doesn't look ugly): =IF(COUNTIF(E$2:E$6, C2)>0, 1, "") 从您的示例开始,您将在D列中放入以下公式(将文本设置为白色,以便工作簿看起来不​​丑): =IF(COUNTIF(E$2:E$6, C2)>0, 1, "")

Then your Criteria3 updates such that you have: =SUM(COUNIFS(A2:A11, "TRUE", B2:B11, "TRUE", D2:D11, 1)) 然后你的Criteria3更新,你有: =SUM(COUNIFS(A2:A11, "TRUE", B2:B11, "TRUE", D2:D11, 1))

If that's non-ideal, the only other way I can think of would be to use a macro to get that SUM for you. 如果那是不理想的,我能想到的唯一另一种方法就是使用宏来为你获取SUM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM