• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

CountIF, CountIFs

rod411

New Member
=COUNTIFS(Class!D4:D27,"II D",D4:D27,"II C")

I need the formula to count the number of cells with "II D" and "II C" in the cell range D4:D27 in the Class worksheet.
 

Attachments

Hi ,

The explanation for why your posted formula does not work is as follows :

The COUNTIF function returns data which satisfies one criterion ; suppose you want to see how many cells in the range Class!D4:D27 have the text II D in them ; you can use the formula :

=COUNTIF(Class!D4:D27,"II D")

Now , if you want to see how many cells in the same range satisfy two criteria , such as II C and II D , it is not really an AND as we have written in English ; it is actually an OR. This is because logically , one cell can only have either II C or II D , and not both i.e. one cell cannot both be II C and II D at the same time.

The COUNTIFS function returns the result of data satisfying two criteria , but doing this at the same time ; for example , we can use the COUNTIFS function to tell us how many numbers in a given range are :

ODD and GREATER THAN 10

ODD and MULTIPLES OF 3

This is because these two criteria are not mutually exclusive , since there can be data which satisfies both the criteria at the same time.

However , we cannot use the COUNTIFS function to tell us how many cells are ZERO and GREATER THAN 0 , since what we mean by the word and is actually OR , since the same cell cannot have a number which is 0 and greater than 0 at the same time.

The solution in cases where the criteria are mutually exclusive is to use two or more COUNTIF statements , depending on how many criteria are being used , or use the array construct that Misra has posted.

Narayan
 
Back
Top