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
| Argument | Type | Required | What it does |
|---|---|---|---|
range | range | yes | The cells that the criterion is tested against. |
criterion | any | yes | The condition: a value, a text, a comparison such as ">4", or a pattern with * and ?. |
sum_range | range | no | The cells to add up. If you leave it out, range itself is summed. |
Examples
The examples use this table, starting in A1:
| Region | Product | Units | Price |
| North | Pen | 10 | 2.5 |
| South | Pen | 4 | 2.5 |
| North | Book | 3 | 12 |
| East | Book | 8 | 12 |
| South | Lamp | 5 | 30 |
=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.