I need to sum values only IF a condition is true, help! (sumif)

We can do this in excel with a single formula:

  • SUMIF: sum the values in a range that meet criteria that you specify

Syntax

=SUMIF(look_in_this_range, for_this_criteria, sum_these_values)

Example

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

The Steps – Sumif

look_in_this_range : look at the colours column (range)

=SUMIF(colours column

for_this_criteria: Is the colour Green (criteria)

=SUMIF(colours column, is the colour green

sum_these_values : Sum the Numbers column if true (sum_range)

=SUMIF(colours column, is the colour green, sum the Number column)

We will be returning the sum of the 2nd and 4th values from our sum_range. Therefore, We must ensure to start our sum_range from the same row as our look up range!

Result

formula

=SUMIF(B3:B7,F3,D3:D7)

output

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