
Adding or counting values that meet certain conditions is one of the most common jobs in Excel. Four functions cover it: SUMIF, SUMIFS, COUNTIF and COUNTIFS.
In the examples, column A holds dates, B regions, C products and D amounts (rows 2 to 500).
SUMIF: one condition
=SUMIF(B2:B500,"North",D2:D500)This returns total sales for the North region. The structure is SUMIF(criteria_range, criteria, sum_range). Taking the condition from a cell makes the report flexible: =SUMIF(B2:B500,G2,D2:D500).
SUMIFS: several conditions
In SUMIFS the range to add comes first, followed by pairs of criteria:
=SUMIFS(D2:D500,B2:B500,"North",C2:C500,"Laptop")All conditions must be met at once (AND logic). You can use SUMIFS for a single condition too; sticking to one structure reduces mistakes.
Sum between two dates
With the start date in G1 and the end date in G2:
=SUMIFS(D2:D500,A2:A500,">="&G1,A2:A500,"<="&G2)Comparison operators go in quotes and are joined to the cell reference with &. For one month, put the first day in G1 and calculate the end with EOMONTH(G1,0).
Wildcards and blank cells
| Criteria | Meaning |
|---|---|
"Lap*" | Starts with Lap |
"*cable*" | Contains "cable" |
"???" | Exactly 3 characters |
"<>" | Not blank |
"" | Blank |
"<>Cancelled" | Anything except Cancelled |
COUNTIF and COUNTIFS: conditional counts
=COUNTIF(B2:B500,"North")
=COUNTIFS(B2:B500,"North",D2:D500,">10000")The first counts sales in the North, the second counts North sales above 10,000. For averages, AVERAGEIFS works the same way.
OR logic: "North or South"
SUMIFS joins conditions with AND. For OR there are two options:
=SUMIF(B2:B500,"North",D2:D500)+SUMIF(B2:B500,"South",D2:D500)
=SUM(SUMIFS(D2:D500,B2:B500,{"North","South"}))The array constant in the second formula runs SUMIFS once per region and SUM adds the results.
A summary that grows by itself
In Microsoft 365, spill the region list into G2 with =UNIQUE(B2:B500) and put this formula next to it. The summary grows as new regions appear:
=SUMIFS(D2:D500,B2:B500,G2#)Common mistakes
- Ranges of different sizes: all ranges must have the same number of rows, otherwise you get #VALUE!.
- Numbers stored as text: if the total is 0, look for green triangles in the amount column.
- Hidden spaces: "North " and "North" are different. Clean the data with TRIM.
- Ranges that move when copied: lock them with $, or convert the data to a table and use structured references such as
Sales[Amount].
Step-by-step example: a sales report by region, product and month
From a list with A: Date, B: Region, C: Product, D: Amount, build totals by region and month on a report sheet:
| Question | Formula |
|---|---|
| Total sales for North | =SUMIF(B2:B1000,"North",D2:D1000) |
| Total for "Product A" in North | =SUMIFS(D2:D1000,B2:B1000,"North",C2:C1000,"Product A") |
| October 2026 total | =SUMIFS(D2:D1000,A2:A1000,">="&DATE(2026,10,1),A2:A1000,"<="&DATE(2026,10,31)) |
| Total for North and South | =SUMIF(B2:B1000,"North",D2:D1000)+SUMIF(B2:B1000,"South",D2:D1000) |
| Average sale (by region) | =AVERAGEIF(B2:B1000,"North",D2:D1000) |
| Number of records | =COUNTIFS(B2:B1000,"North",C2:C1000,"Product A") |
Write region and product names in cells on the report sheet and refer to the cells in the formula (mixed references like $A2, B$1); by dragging one formula in both row and column directions you can fill the whole table. For mixed references see our Excel tips guide.
Checking errors: why does the formula return zero?
| Cause | Fix |
|---|---|
| Range sizes differ | Keep all ranges the same number of rows |
| Amounts are stored as text | Convert to numbers (see our data cleaning guide) |
| Criterion spelled differently | Spaces, case, accented characters |
| Dates are text | Convert with DATEVALUE |
| Criterion operator missing | Use quotes and & as in ">="&A1 |
| Slowness from a full-column reference | Use the data range or a table column |
SUMIFS or a pivot table?
For a few fixed totals use SUMIFS; for multi-dimensional, constantly changing reports a pivot table is faster and more flexible (see our pivot table guide). You can use both: explore with a pivot table, and keep fixed indicators on the report sheet with SUMIFS. For a dynamic report see our dashboard guide.
Frequently asked questions
Why is the argument order different in SUMIF and SUMIFS? SUMIF is (range, criteria, sum_range), while SUMIFS takes the sum range first (sum_range, criteria_range1, criteria1…).
How do I set an "or" condition? Add SUMIFs or use SUM(SUMIF(range,{"North","South"},sum)).
Can I read several criteria from a cell range? Yes; it is possible with SUMPRODUCT or dynamic array formulas.
Partial text match? Wildcard: "*net*".
Case-sensitive summing? With SUMPRODUCT(EXACT(...)*...).
Serkan Akyürek is the founder and author of toolrota; he writes step-by-step guides on Excel, AI, the cloud, personal finance and digital security.