Going Stellar

Home/Google Sheets reference

Google Sheets function · Math

SUMIF in Google Sheets: syntax and examples

SUMIF tests every cell of range against one criterion and adds the matching cells of sum_range. It is the shortest way to get a total per region, product or status.

Syntax

SUMIF(range, criterion, [sum_range])

Arguments

ArgumentTypeRequiredWhat it does
rangerangeyesThe cells that the criterion is tested against.
criterionanyyesThe condition: a value, a text, a comparison such as ">4", or a pattern with * and ?.
sum_rangerangenoThe cells to add up. If you leave it out, range itself is summed.

Examples

The examples use this table, starting in A1:

RegionProductUnitsPrice
NorthPen102.5
SouthPen42.5
NorthBook312
EastBook812
SouthLamp530
=SUMIF(A2:A6, "North", C2:C6)

Result: 13

Units sold in the North region: rows 2 and 4 match, so 10 + 3.

Run in a Google Sheet (English US locale) on .

=SUMIF(C2:C6, ">4")

Result: 23

Without sum_range, the tested cells are the ones added: only values above 4 count.

Run in a Google Sheet (English US locale) on .

=SUMIF(B2:B6, "B*", C2:C6)

Result: 11

A wildcard: every product that starts with B, here Book on two rows.

Run in a Google Sheet (English US locale) on .

=SUMIF(A2:A6, "<>North", C2:C6)

Result: 17

Everything except one region: the operator <> means not equal.

Run in a Google Sheet (English US locale) on .

=SUMIF(A2:A6, "north", C2:C6)

Result: 13

Lowercase criterion, capitalized data: the test ignores case, so the result is the same as the first example.

Run in a Google Sheet (English US locale) on .

Common errors

  • An operator inside the criterion must be part of a quoted text. =SUMIF(C2:C6, >4) is a syntax error (#ERROR!), while ">4" works.
  • SUMIF takes one condition only. For two or more conditions use SUMIFS, where sum_range comes first.
  • sum_range is lined up with range by its top-left cell and stretched to the same size. A range shifted by one row, such as C3:C7, returns 12 instead of 13 with no error, so start both on the same row.
  • A criterion written as text, such as "4", still matches the number 4. Quotes do not turn the test into a text comparison.

Compared with Excel

Same syntax as Excel SUMIF. Excel and Sheets both have SUMIFS for several conditions.

Sources

  1. SUMIF (Docs Editors Help)

Markdown version · All functions