I need to count values only IF a condition is true, help! (countif)

We can do this in excel with a single formula:

  • COUNTIF: count the values in a range that meet criteria that you specify

Syntax

=COUNTIF(look_in_this_range, for_this_criteria)

Example

Let’s use an example to illustrate the formula. We want to count all values in our range which have the colour “Green” (the black cells).

The Steps

look_in_this_range : look at the colours column (range)

=COUNTIF(colours column

for_this_criteria: Is the colour Green (criteria)

=COUNTIF(colours column, is the colour green)

Result

formula

=COUNTIF(D3:D7,F3)

output

And there you have it, 2 is the total number of our Green values!