RedP
RedP

Reputation: 1

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.

Upvotes: 0

Views: 163

Answers (4)

Manuel
Manuel

Reputation: 297

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,"<>")

Upvotes: 0

Chicago Excel User
Chicago Excel User

Reputation: 263

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.

Upvotes: 0

Richard Lusch
Richard Lusch

Reputation: 1190

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.

Upvotes: 0

Andreas N.
Andreas N.

Reputation: 246

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)

Upvotes: 1

Related Questions