Conditional totals function
SUMIF function in Google Sheets and Excel
SUMIF adds the numbers in a range that meet one condition, such as every order in the Plants category.
Checked against Microsoft's and Google's documentation on · Example calculated on a live sheet
- Excel 2016
- Excel 2019
- Excel 2021
- Excel 2024
- Microsoft 365
- Google Sheets
Syntax
SUMIF(range, criteria, [sum_range])Arguments in [brackets] are optional. Google Sheets writes it SUMIF(range, criterion, [sum_range]).
Example
=SUMIF(E2:E13,"Plants",I2:I13) reads: Look down the Category column E2:E13 for "Plants" and add the matching rows' totals from I2:I13.
| A | B | C | D | E | F | G | H | I | J | K | L | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Order | Date | Customer | Product | Category | Qty | Price | Status | Total | Plants revenue | $229.00 | |
| 2 | 1001 | 2 Mar 2026 | Mara Okafor | Monstera | Plants | 1 | $34.00 | Shipped | $34.00 | |||
| 3 | 1002 | 2 Mar 2026 | Jonas Lind | Terracotta pot | Pots | 3 | $12.50 | Shipped | $37.50 | |||
| 4 | 1003 | 3 Mar 2026 | Priya Raman | Snake plant | Plants | 2 | $22.00 | Shipped | $44.00 | |||
| 5 | 1004 | 4 Mar 2026 | Tomás Ruiz | Watering can | Tools | 1 | $18.00 | Pending | $18.00 | |||
| 6 | 1005 | 5 Mar 2026 | Elif Demir | Fern | Plants | 4 | $9.50 | Shipped | $38.00 | |||
| 7 | 1006 | 5 Mar 2026 | Mara Okafor | Potting mix | Soil | 2 | $7.25 | Returned | $14.50 | |||
| 8 | 1007 | 6 Mar 2026 | Kenji Mori | Pruning shears | Tools | 1 | $24.00 | Shipped | $24.00 | |||
| 9 | 1008 | 7 Mar 2026 | Ines Varga | Ceramic pot | Pots | 2 | $19.00 | Pending | $38.00 | |||
| 10 | 1009 | 8 Mar 2026 | Jonas Lind | Monstera | Plants | 1 | $34.00 | Shipped | $34.00 | |||
| 11 | 1010 | 9 Mar 2026 | Sofia Rossi | Fern | Plants | 6 | $9.50 | Shipped | $57.00 | |||
| 12 | 1011 | 10 Mar 2026 | Priya Raman | Potting mix | Soil | 5 | $7.25 | Shipped | $36.25 | |||
| 13 | 1012 | 11 Mar 2026 | Leo Brandt | Snake plant | Plants | 1 | $22.00 | Pending | $22.00 |
L1 shows $229.00: the Totals of the six Plants orders, 34 + 44 + 38 + 34 + 57 + 22.
How the spreadsheet calculates it
Adds up the values in I2:I13 on the rows where E2:E13 is equal to "Plants".
- 1. SUMIF: Adds up the values in
I2:I13on the rows whereE2:E13is equal to"Plants".range=`E2:E13`: the cells to checkcriteria=`"Plants"`: what to matchsum_range=`I2:I13`: the cells to add for the matching rows
More SUMIF examples
=SUMIF(G2:G13,">20")Every price above 20 (no sum range: the tested cells are added).=SUMIF($E$2:$E$13,L2,$I$2:$I$13)The total for the category in L2, ready to fill down a summary table.=SUMIF(D2:D13,"*pot*",I2:I13)Totals of products with "pot" in their name.=SUMIF(H2:H13,"<>Returned",I2:I13)Totals of every order that wasn't returned.=SUMIF(B2:B13,">="&L1,I2:I13)Totals of orders on or after the date in L1.
Paste any of these into the formula explainer to see it step by step.
Tips
- Point criteria at a cell holding the category, so one formula fills down a summary table.
- Lock range and sum_range with
$before filling down. - Keep range and sum_range the same size and starting on the same row.
- Use "<>" to sum everything except one value:
"<>Returned".
What SUMIF is used for
Sales per category or region, spend per budget category, hours per project, and summary tables where a list of categories sits next to one SUMIF each, the criteria pointing at the category cell.
Arguments
| Argument | Required | What it is |
|---|---|---|
| range | Yes | The cells to test against the condition, such as the Category column E2:E13. |
| criteria | Yes | The condition: a value ("Plants"), a comparison in quotes (">20"), a cell (L2) or a wildcard ("pot").Watch out: A comparison with a cell needs &: ">"&L2, not ">L2". |
| sum_range | No | The cells to add, row for row with range. Left out, SUMIF adds the matching cells of range itself.Watch out: Microsoft documents that a sum_range of a different size is resized to match range from its first cell, which can quietly add the wrong cells. |
Common mistakes
Putting the sum range first: in SUMIF it comes last.
Ranges of different heights: rows no longer line up.
Putting the cell inside the quotes:
">L1"compares with the letters L1, so nothing matches and the total is 0. Write">"&L1.Adding two SUMIFs to get "Plants and Shipped": that adds the two groups (an OR, counting some rows twice). For several conditions on the same row, use
SUMIFS.
In Google Sheets
Google Sheets' SUMIF takes the same three arguments, written SUMIF(range, criterion, [sum_range]), with the same optional sum range.
Errors you may see with SUMIF
- #VALUE!: Criteria longer than 255 characters, or ranges in another workbook that's closed (Microsoft's SUMIF troubleshooting page).
- #SPILL!: A whole range given as criteria (E2:E13 instead of one cell) returns one total per value in dynamic-array Excel and can spill into filled cells. How to fix it.
Questions
Why does SUMIF return 0?
Usually the criteria doesn't match exactly (a typo, a trailing space, singular vs plural) or the sum range holds text. SUMIFS returns 0 walks through each cause; they apply to SUMIF too.
How do I sum if a cell contains a word?
Use wildcards: =SUMIF(D2:D13,"*pot*",I2:I13) adds the totals of every product with "pot" anywhere in its name. ? stands for exactly one character.
How do I sum values greater than a number?
Put the comparison in quotes and leave out sum_range to add the tested cells themselves: =SUMIF(G2:G13,">20") adds every price above 20.
Should I use SUMIF or SUMIFS?
SUMIFS does everything SUMIF does and takes more conditions, with the sum range first. Many people use SUMIFS everywhere for one order of arguments. See SUMIF vs SUMIFS.
Sources
Official documentation the facts on this page were checked against.