SUMIF, COUNTIF and SUMIFS: When to Use Each One
SUMIF, COUNTIF and SUMIFS: When to Use Each One
SUMIF adds up numbers that meet one condition, COUNTIF counts how many cells meet one condition, and SUMIFS extends SUMIF to handle multiple conditions at once. If you only need one condition, SUMIF or COUNTIF is simpler to read. The moment you need two or more conditions together, jump straight to SUMIFS rather than trying to stack separate SUMIFs — it'll save you a headache later.
Early in my first office job, before anyone showed me these existed, I used to reconcile expense reports by literally printing them out and going down the page with a highlighter, matching entries by eye and adding totals on a calculator. It sounds ridiculous typing it out now, but nobody had told me any different, and the job got done, just painfully slowly. A colleague eventually looked over my shoulder, asked why I wasn't just using SUMIF, and I genuinely didn't know it existed. That one conversation probably saved me hundreds of hours over the following few years, and it's part of why I don't assume anyone reading this blog is silly for not knowing something — most of us are just one conversation away from a better method, same as I was.
How does SUMIF actually work?
SUMIF adds up values in one range, based on a condition checked in another range.
=SUMIF(range, criteria, [sum_range])
Adding up total sales for a specific region:
=SUMIF(B2:B200, "NSW", C2:C200)
Here, B2:B200 is checked for the condition ("NSW"), and C2:C200 is the range that actually gets summed wherever that condition is true. If you're summing the same range you're checking, you can drop the third argument entirely — for example, =SUMIF(C2:C200, ">1000") adds up every value in that range over $1,000.
How is COUNTIF different from SUMIF?
COUNTIF counts how many cells match a condition, rather than adding up values. Same basic structure, one fewer argument:
=COUNTIF(range, criteria)
Counting how many sales entries came from NSW:
=COUNTIF(B2:B200, "NSW")
A genuinely useful trick a lot of beginners miss: COUNTIF is also the quickest way to spot duplicates without touching Remove Duplicates or building a pivot table.
=COUNTIF(A2:A200, A2)
Copied down the column, any result greater than 1 means that value appears more than once somewhere in the range.
Why do I need SUMIFS instead of just using SUMIF twice?
This is where people trip themselves up. SUMIF only accepts one condition. If you try to check two conditions by nesting or stacking SUMIF formulas, you either get the wrong number or a formula that's much harder to read than it needs to be. SUMIFS was built specifically to handle multiple conditions cleanly in one formula.
=SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)
Notice the sum range comes first in SUMIFS, which is the opposite order from SUMIF — this catches almost everyone out at least once.
Total sales for NSW, in the month of March, over $500:
=SUMIFS(D2:D200, B2:B200, "NSW", C2:C200, "March", D2:D200, ">500")
Each condition gets its own range-and-criteria pair, and you can chain as many as you need. This one formula replaces what would otherwise be a messy combination of helper columns or an awkward SUMPRODUCT formula.
What's the difference between SUMIFS and COUNTIFS?
Exactly the same relationship as SUMIF and COUNTIF — COUNTIFS counts rows matching multiple conditions instead of summing a value.
=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)
Counting how many NSW sales happened in March:
=COUNTIFS(B2:B200, "NSW", C2:C200, "March")
| Function | Condition count | Returns |
|---|---|---|
| SUMIF | One | A sum |
| COUNTIF | One | A count |
| SUMIFS | Multiple | A sum |
| COUNTIFS | Multiple | A count |
Why is my SUMIF or SUMIFS returning zero?
The usual suspects, roughly in order of how often I've seen them:
- Text vs number mismatch. If your criteria is a number but the column actually contains numbers stored as text (or vice versa), nothing matches.
- Extra spaces in the criteria column. A cell that looks like "NSW" but actually contains "NSW " (trailing space) won't match a clean "NSW" criteria.
- Wrong argument order in SUMIFS. Remember, sum_range comes first in SUMIFS, unlike SUMIF where it comes last. Mixing these up is probably the most common mistake with this formula.
- Ranges of different sizes. All ranges in a SUMIFS formula need to be the exact same number of rows, or Excel throws an error rather than guessing.
- Date criteria typed as plain text. Comparing dates needs actual date values, not text that merely looks like a date — check that your date column is genuinely formatted as dates.
Can I use wildcards or comparison operators in the criteria?
Yes, and this is worth knowing because it opens up a lot more than exact-match conditions.
">500"— greater than 500"<>NSW"— not equal to NSW"N*"— starts with N (asterisk as wildcard)"*Corp*"— contains "Corp" anywhere in the text
Combining a wildcard with SUMIF, summing sales for any client whose name contains "Corp":
=SUMIF(A2:A200, "*Corp*", C2:C200)
Should I use SUMIFS or a pivot table for this kind of thing?
If you've read my post on "pivot tables", this trade-off will sound familiar. SUMIFS is better when the result needs to update live and feed into other formulas or a dashboard. Pivot tables are better when you're exploring data interactively and want to drag fields around to see different views without writing formulas at all.
I lean on SUMIFS constantly for anything that needs to sit inside a bigger workbook and stay live, and I reach for a pivot table when I just want to poke around a dataset and understand it before deciding what to build.
FAQ
Can SUMIFS handle an "OR" condition, like NSW or VIC?
Not directly within one SUMIFS — each condition pair is treated as AND. For an OR relationship, either add two separate SUMIFS formulas together, or use SUMIFS with an array constant like SUM(SUMIFS(D2:D200, B2:B200, {"NSW","VIC"})).
Why does COUNTIF count blank cells as a match sometimes?
If your criteria is "" (empty string), COUNTIF will match genuinely blank cells but not cells containing a formula that returns an empty result — those aren't truly blank to Excel, even though they look empty.
Is there a limit to how many conditions SUMIFS can handle? Up to 127 range-and-criteria pairs, which is far more than you'll realistically ever need in a normal spreadsheet.
Can I reference a cell instead of typing the criteria directly?
Yes, and it's generally better practice — =SUMIFS(D2:D200, B2:B200, F1) referencing a cell F1 is easier to update than editing the formula itself every time the condition changes.
Does SUMIFS work with dates as a range condition, like "between two dates"?
Yes — use two conditions on the same date column: =SUMIFS(D2:D200, C2:C200, ">="&F1, C2:C200, "<="&F2), where F1 and F2 hold your start and end dates.
Can I use SUMIF or COUNTIF to look up a value, instead of VLOOKUP?
Not quite the same job — SUMIF and COUNTIF are built for calculating across matching rows, not returning a single specific value from another column the way VLOOKUP or XLOOKUP does. If what you actually need is "find this value and bring back a matching result," see my post on VLOOKUP vs XLOOKUP instead.
Comments
Post a Comment