The SUMIF function
Adds the cells that meet one condition. The condition can be checked in the same range or in another column.
How to use SUMIF
SUMIF is a total with a filter. Picture a pile of receipts where you only want to add the ones from one shop. SUMIF looks at each row, checks the condition, and counts the amount only when the condition is met.
You give it three things: the range to check (the shop names), the condition ("North"), and the range that holds the amounts to add. In =SUMIF(A2:A10,"North",C2:C10) the two ranges line up row by row. If you leave out the last argument, SUMIF adds the cells it checked, as in =SUMIF(C2:C10,">300").
The condition can be text, a number, or a comparison inside quotes such as ">300" or "<>North". Wildcards let you match part of a text: "*shoe*" matches every cell with shoe somewhere in it. To compare with a value in a cell, join the two with &, like ">"&E1.
SUMIF holds one condition only. When region and product must both match, use SUMIFS, which puts the sum range first. To count the matching rows instead of adding them, use COUNTIF.
Syntax
SUMIF(range, criteria, [sum_range])- range
- The cells the condition is checked against.
- criteria
- The condition, such as "North", ">300" or a cell like E1.
- sum_range (optional)
- The cells to add. If left out, range itself is added.
Examples
=SUMIF(1A2:A6,2"North",3C2:C6)| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Region | Product | Sales | 1170 | |
| 2 | North | Shoes | 500 | ||
| 3 | South | Shoes | 300 | ||
| 4 | North | Bags | 250 | ||
| 5 | North | Shoes | 420 | ||
| 6 | South | Bags | 180 |
In plain words: Add up 3the sales in C2:C6 on the rows where 1the region in A2:A6 is 2North.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Region | Product | Sales | 920 | |
| 2 | North | Shoes | 500 | ||
| 3 | South | Shoes | 300 | ||
| 4 | North | Bags | 250 | ||
| 5 | North | Shoes | 420 | ||
| 6 | South | Bags | 180 |
Common SUMIF mistakes
SUMIF returns 0 although matching rows exist
Usually the cells do not match exactly. Numbers stored as text in the sum range are skipped, and a category like
Northwith a space at the end is not the same asNorth. Turn the text into real numbers, clean the names with TRIM, or use a wildcard such as"North*".A condition like ">E1" adds nothing
Inside quotes, E1 is just the two letters E1. Join the operator and the cell with &:
=SUMIF(C2:C6,">"&E1).SUMIF rejects a condition such as >300 written without quotes
A condition with an operator is text, so it needs quotes:
=SUMIF(C2:C6,">300").SUMIF adds the wrong rows
SUMIF lines the sum range up with the range from its first cell. In
=SUMIF(A2:A6,"North",C3:C7)A2 is paired with C3, so every amount is read one row too low. Start both ranges in the same row.
Practice SUMIF
Read the guide
- Excel test for a job interview: what it looks like and how to practice
- Free Excel course online: learn Excel from your first formula to job-ready
- Pivot tables explained, and the formulas that do the same job
- Excel for finance and accounting: the skills you actually use
- How to make a graph in Excel: column, line and pie charts step by step
- Excel budget template: free download and the formulas behind it
- Excel practice data: free datasets with tasks and answers
- Pivot table practice: 15 exercises with answers on real sales data
- Excel inventory data: free practice file with tasks and answers
- Excel customer data: free practice file with tasks and answers
- Excel finance data: free practice file with tasks and answers
Questions
How do I use SUMIF with a cell as the condition?
Point the criteria at the cell, like =SUMIF(A2:A6,E1,C2:C6). For a comparison, join the operator with &: ">"&E1.
How do I sum cells that contain certain text?
Wrap the text in asterisks: =SUMIF(B2:B6,"*shoe*",C2:C6) adds the sales on every row where the product contains shoe. A question mark stands for exactly one character. Text matching ignores upper and lower case.
How do I sum everything except one value?
Put <> in front of the value: =SUMIF(A2:A6,"<>North",C2:C6). If the value is in a cell, write "<>"&E1.
Can SUMIF use more than one condition?
No, SUMIF has room for one. Use SUMIFS when every condition must be true, or add two SUMIF formulas when either condition may be true: =SUMIF(A2:A6,"North",C2:C6)+SUMIF(A2:A6,"South",C2:C6).