简体   繁体   English

用AND&OR的excel countifs

[英]excel countifs with AND & OR

I'm trying to create an Excel function that counts instances that meet 3 criteria. 我正在尝试创建一个Excel函数,该函数计算满足3个条件的实例。 For example data in sample data , I want to: 例如,示例数据中的数据 ,我想:

1)For each type of 'Structure' count number of rows in which 2)'Horizontal' is greater than zero, OR 3)'Vertical' is greater than zero 1)对于每种类型的“结构”,计算其中2)“水平”大于零或3)“垂直”大于零的行数

Expected result for example data in column D. 预期结果,例如D列中的数据。

An array formula of the type 类型的数组公式

=SUM(IF(($B$2:$B$7>0)+($C$2:$C$7>0),1,0)) = SUM(IF((($ B $ 2:$ B $ 7> 0)+($ C $ 2:$ C $ 7> 0),1,0))

counts in accordance with criteria 2) and 3) but does not group by 'Structure'. 根据条件2)和3)进行计数,但不按“结构”分组。

Any thoughts? 有什么想法吗?

Much appreciated. 非常感激。

Edit following comment by Scott Cranger 编辑 Scott Cranger的以下评论

If F2 contains the Structure type, then: 如果F2包含结构类型,则:

G2: =SUMPRODUCT(--((Structure_Type=F2)*((Horizontal>0)+(Vertical>0))>0))

where Structure_Type, Horizontal, and Vertical are the ranges containing those elements. 其中Structure_Type,Horizo​​ntal和Vertical是包含这些元素的范围。 This formula is normally entered. 通常输入此公式。

Try this Array formula: 试试这个数组公式:

=SUM(IF(($A$2:$A$7= A2)*(($B$2:$B$7>0)+($C$2:$C$7>0)),1,0))

Remember to use Ctrl-Shift-Enter. 请记住使用Ctrl-Shift-Enter。

The * is used for And and the + for Or . *用于And ,而+用于Or So this will pick up only those that have Structure in column A and has a greater than 0 in one or both of column B or column C 因此,这只会选择那些在A列中具有Structure并且在B列或C列之一或两者中都大于0的那些

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

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