简体   繁体   中英

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.

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.

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

ctrl + shift + enter to evaluate SUM as an array formula (adding the {} brackets)

You can derive it by 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,"<>")

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. I would recommend to use the countifs function instead.

            =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. 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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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