Reputation: 735
I have a list of members with their birthday. I'd like to count the number of members whose birth month falls in July or August. I tried the following COUNTIFS formula but it did not work
=COUNTIFS(AH3:AH135,"=7",AH3:AH135,"=8")------ formula(1) gave zero
while individual COUNTIFS worked fine
=COUNTIFS(AH3:AH135,"=7") gave 13 and
=COUNTIFS(AH3:AH135,"=8") gave 6
I then defined the range AH3:AH135 as month and tried the following formula. It still did not work.
=COUNTIF(month,"=7",month,"=8") gave zero
I even tried the following formula and it gave 4, not the correct answer
=COUNTIFS(AH3:AH135,OR("=7","=8"))------- formula(2)
I had to resort to the following formula to get the correct answer
=SUM(COUNTIFS(AH3:AH135,{"=7","=8"}) gave 19
My questions are:
Why didn't formula(1) work? The only reason I can think of is that ranges must be unique. Can't have the same range more than once in the formula.
Why did formula(2) give 4? I have no clue what it was doing.
Upvotes: 1
Views: 272
Reputation: 7332
OR("=7","=8")
results to an error. and if its counting the number of errors in your range.Solution:
The formula that you could use in your case is =COUNTIF(AH3:AH135,"=7") + COUNTIF(AH3:AH135,"=8")
Upvotes: 1