简体   繁体   English

使用公式时值错误excel错误

[英]error in value excel error while using a formula

I would like to find the number of dead black cats in the following table using excel formula. 我想在下表中使用excel公式查找死黑猫的数量

Column B   Column C    Column D      Column E
(Animal)   (Color)      (DOB)      (DateOfDeath)
  Cat       Black     03/08/2010    03/08/2015
  Cat       White     03/08/2010
  Cat       Black     03/08/2010    03/08/2015
  Dog       White     03/08/2015    03/08/2015
  Dog       White     03/08/2015    03/08/2015
  Cow       Black     03/08/2015    
  Cat       Black     03/08/2015    
  Cat       White     03/08/2016    

The formula which I used is: 我使用的公式是:

=AGGREGATE(2, 6, (B3:B10="Cat")*(C3:C10="Black")*(NOT(ISBLANK(E3:E10))))

For some reason, it is not working, I don't know what mistake I have made. 由于某种原因,它不起作用,我不知道自己犯了什么错误。

Since the argument (B3:B10="Cat")*(C3:C10="Black")*(NOT(ISBLANK(E3:E10))) is equivalent to an array of 0 and 1, you could just sum it. 由于参数(B3:B10 =“ Cat”)*(C3:C10 =“ Black”)*(NOT(ISBLANK(E3:E10)))等效于0和1的数组,因此可以将其求和。

{=SUM((B3:B10="Cat")*(C3:C10="Black")*(NOT(ISBLANK(E3:E10))))}

ctrl + shift + enter to evaluate SUM as an array formula (adding the {} brackets) ctrl + shift + Enter以将SUM评估为数组公式(加上{}括号)

You can derive it by Total Number of Black Cats - Total No of Black Cats with empty DateofDeath 您可以通过Total Number of Black Cats Total No of Black Cats with empty DateofDeath - Total No of Black Cats with empty DateofDeath Total Number of Black Cats Total No of Black Cats with empty DateofDeath得出它

=COUNTIFS(B2:B9,"Black",A2:A9,"Cat") - COUNTIFS(B2:B9,"Black",A2:A9,"Cat",D2:D9,"")

Alternative Direct Method would be =COUNTIFS(B:B,"Cat",C:C,"Black",E:E,"<>") 替代直接方法为=COUNTIFS(B:B,"Cat",C:C,"Black",E:E,"<>")

I have not worked with the Aggregate function yet, looking at it though it seems to not necessarily fit what you are trying to do. 我尚未使用Aggregate函数,尽管似乎不一定适合您要尝试的功能,但仍在研究它。 I would recommend to use the countifs function instead. 我建议改为使用countifs函数。

            =COUNTIFS($B$2:$B$9,AnimalType,$C$2:$C$9,AnimalColor,$E$2:$E$9,">0")

This function evaluates each criteria, in columns B, C, and D against AnimalType, AnimalColor, and whether the date is greater than zero. 此函数针对AnimalType,AnimalColor以及日期是否大于零来评估B,C和D列中的每个条件。 I duplicated the data set and entered the formula which generated the correct results. 我复制了数据集并输入了生成正确结果的公式。

Keep in mind that not all aggregate functions handle arrays (only function numbers 14 and above handle arrays). 请记住,并非所有聚合函数都处理数组(仅14号及以上的函数处理数组)。

2nd - you cannot mutply trues and falses. 第二-您不能混淆是非。 You need to conver them to number values first by adding -- in front. 您需要先在前面加-将它们转换为数字值。

If you would like to do this calculation using arrays I'd suggest using this 如果您想使用数组进行此计算,建议使用

=SUMPRODUCT(--(B3:B10="Cat")*--(C3:C10="Black")*--(NOT(ISBLANK(E3:E10))))

Otherwise Use COUNTIFS as suggested by the above poster. 否则,按照上述海报的建议使用COUNTIFS。

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

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