Conditional totals · About 5 minutes
Add up with two conditions using SUMIFS
SUMIF handles one condition. SUMIFS handles as many as you need, and a row is added only when it passes every one.
SUMIFS puts the range to add up first, then pairs of "where to look, what to look for". =SUMIFS( reads as "add up D2 to D8 where the City is Dallas and the Month is Jan".
Every range in SUMIFS must cover the same rows. Here they all run from row 2 to row 8.
Part of Plus
Free during our founding launch: sign in to unlock this lesson's exercises, the timed practice sets and the rest of Plus. The free lessons stay free, with no account needed.
What SUMIFS does
SUMIFS adds up the rows that pass every condition you give it, like the hours team Red spent on Build. A row that fails any one condition is left out.
It is SUMIF with room for more tests. Use it when one condition is not enough to pick out the rows you want, and the total still updates when the data changes.
How to write SUMIFS
=SUMIFS(
- sum_range
- The numbers to add. Unlike SUMIF, this comes first.
- criteria_range1
- The first column to test, like the teams in A2:A7.
- criteria1
- The test for that column, like
"Red",">5"or a cell such as A8. - criteria_range2, criteria2, ...
- More pairs of "where to look, what to look for". Excel accepts up to 127 pairs.
SUMIFS worked example
A log records hours by team and task. In C8, add up the hours team Red spent on Build.
| A | B | C | |
|---|---|---|---|
| 1 | Team | Task | Hours |
| 2 | Red | Build | 6 |
| 3 | Blue | Build | 4 |
| 4 | Red | Test | 3 |
| 5 | Red | Build | 5 |
| 6 | Blue | Test | 7 |
| 7 | Red | Build | 2 |
| 8 | Red | Build | 13 |
=SUMIFS( C2:C7, A2:A7, A8, B2:B7, B8)Add up the hours in C2 to C7 where the team matches A8 and the task matches B8: 6 + 5 + 2 = 13.Common SUMIFS mistakes
The total is off after copying a SUMIF
SUMIFS takes the range to add first. Move it from the end to the front: =SUMIFS(, not SUMIF's order.
The cell shows an error
Every range must cover the same rows. Make them all run from row 2 to row 7, like C2:C7, A2:A7 and B2:B7.
Red or Blue gives 0
SUMIFS needs every condition to pass, and no row is both Red and Blue. Add two SUMIFS together, one for each team.
SUMIFS or SUMIF?
Use SUMIF for one condition and SUMIFS for two or more. SUMIFS also works with just one pair, so some people use it every time to keep one order to remember.
Both are in Excel 2007 and later and in Google Sheets. Text tests ignore upper and lower case, so "red" matches Red.
Questions people ask
What is the difference between SUMIF and SUMIFS?
SUMIF takes one condition and puts the range to add last. SUMIFS takes one or more conditions and puts the range to add first.
How do I use SUMIFS between two dates?
Test the date column twice: =SUMIFS(, with the start date in F1 and the end date in F2.
Can SUMIFS use OR logic?
Not on its own, because every condition must be met. Add two SUMIFS together, one for each option.
Why does SUMIFS give #VALUE!?
The ranges are different sizes. Make every range cover the same rows, like C2:C50 and A2:A50.
How many conditions can SUMIFS take?
Up to 127 pairs of range and condition.