[英]Count number of X in Column A when Y is in either Column B or C
Simplified data in columns A, B and C: A、B 和 C 列中的简化数据:
A | B | C
X | | Y
| Y |
X | Y |
Z | | Y
X | |
How to count the number of X when the value of Y is present in column B or C?当 B 或 C 列中存在 Y 的值时,如何计算 X 的数量? (ie. result is 2).
(即结果为 2)。 Was thinking about
COUNTIFS
but can't seem to get the formula right :(正在考虑
COUNTIFS
但似乎无法正确计算公式:(
You can't do this with a single COUNTIFS
, because conditions in COUNTIFS
are AND
, not OR
.您不能使用单个
COUNTIFS
执行此COUNTIFS
,因为COUNTIFS
中的条件是AND
,而不是OR
。 You can do it with multiple COUNTIFS
, or an Array Formula (not recommended - that's a bit overkill for this case)您可以使用多个
COUNTIFS
或数组公式(不推荐 - 在这种情况下有点矫枉过正)
You need to count up all the rows where Column A is X
and Column B is Y
, add all the rows where Column A is X
and Column C is Y
, and then decide of a row where Column A is X
and both Column B and Column C are Y
is possible and/or should be counted twice.你需要计算了所有的行,其中列A是
X
和列B为Y
,添加的所有行,其中列A是X
和C列是Y
,然后再决定一排,其中列A是X
和两列B和C 列是Y
是可能的和/或应该计算两次。
If it is possible, but should not be double-counted, then you will need to subtract all the rows where Column A is X
and Columns B and C are both Y
.如果有可能,但不应该被重复计算,那么你将需要减去所有,其中A列是行
X
和列B和C都是Y
。
=COUNTIFS($A:$A,"X",$B:$B,"Y") + COUNTIFS($A:$A,"X",$C:$C,"Y") - COUNTIFS($A:$A,"X",$B:$B,"Y"",$C:$C,"Y")
If it can't be in both, or you want that to count as 2 rows instead of 1, then you don't need the third COUNTIFS
如果它不能同时存在,或者您希望将其计为 2 行而不是 1,那么您不需要第三个
COUNTIFS
As an Array Formula (using SUMPRODUCT
instead of SUM
, because then we don't need to use Ctrl + Shift + Enter ), for reference:作为数组公式(使用
SUMPRODUCT
而不是SUM
,因为我们不需要使用Ctrl + Shift + Enter ),供参考:
=SUMPRODUCT(--($A:$A="X")*--(--($B:$B="Y")+($C:$C="Y")>0))
(The >0
is so that the OR ( +
) doesn't double-count) (
>0
是为了使OR ( +
) 不会重复计算)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.