【Google Sheets】SUMIF|to sum the numbers if they meet a condition


SUMIF sounds easy to learn as the name speaks for itself.

But, the syntax of SUMIF function looks just intimidating…

 SUMIF

 

to sum numbers in a cells range that have met a condition

SUMIF( range 1, criterion, [range 2 to sum])

range 1:a range tested against criterion [and summed if there’s no range 2]
criterion:a condition applied to range 1
   - if you’d like to sum the amount of sales from carrot, the criterion is “carrot”.
   - if you’d like to sum the amount of sales more than $5, the criterion is “>5”
[range 2 to sum]:a range to be summed if there’s a different range to sum.
   - size of range 1 and 2 must be equal.
   - if not set, range 1 is considered a range to be both summed and tested against a criterion.



※ if a condition is unclear, wildcard can be set.
※If criterion contains a text and logical operators( such as “=”, “<"),
it must be enclosed in double quotation marks, like “apple”, “>5”.
It can be understood intuitively through solving questions.

 Example


Sum all the sales amount greater than $5 within the thick blue border.

Sample Data

 Answer


$19.5

 1, Select the cell D10 and type =SUMIF().
 2, Define the cell range D2:D7 as “range 1”.
 3, Define “>5″(greater than $5) as the criterion


In this case, range 1 and range 2 to sum are the same, aren’t they?
Indeed, as sales amounts are listed in the range D2:D7 and the criterion is also applied on the same range.
How’s it like if there’s “range 2 to sum”, as mentioned earlier –

[range 2 to sum]:a range to be summed if there’s a different range to sum.
Well, let’s see the case where the different range to sum does exist.


Step # 1:Examples if there is range 2 to sum



SUMIF ( range 1, criterion,
range 2 to sum
Adding range 2 separately means a range to be summed is different from range 1 where a condition is applied.


Example 1


If you want to sum the sales amounts for “Carrot”, range 1 where the criterion is supplied is on Column” B” (products), while range 2, to be summed, is on Column “D” (sales).

D10 = SUMIF(B2:B7, “Carrot”, D2:D7)
The size of range 1 and 2 must be equal. The sales amounts to be summed and the products to meet criterion are lined up parallel to each other.

SUMIF( range 1, criterion, [range 2 to sum])
 In this case, The criterion is “Carrot” and range 2 to sum is the cell range D2:D7.


Example 2


Suppose you want to sum the sales amounts if the number of “Qty. Sold” are greater than equal to (>=) 5, range 1 is on Column” C” (Qty. Sold), while range 2 to be summed is on Column “D” (sales).
D10 = SUMIF(C2:C7, “>=5”, D2:D7)
The size of range 1 and 2 must be equal. The sales amounts to be summed and “Qty. Sold” meets criterion are lined up parallel to each other.

SUMIF( range 1, criterion, [range 2 to sum])
 In this case, The criterion is “>=5” and range 2 to sum is the cell range D2:D7.


If there’s no range2, however, a range where a condition is applied and summed are the same like below.


SUMIF(range where criterion’s supplied and summed, criterion)