Lesson 16 of 92 · Free Excel Course
Excel
Excel SUMIF Function: Count, Add and Average Only the Rows You Want
Learn the SUMIF function in Excel, plus COUNTIF and AVERAGEIF: operators, criteria in a cell, wildcards, dates, SUMIFS with multiple conditions and OR.
SUM adds a whole column. But most real questions are pickier: how much did the East region sell? How many orders were over $100? What was the average sale since January? That's what COUNTIF, SUMIF and AVERAGEIF are for. Each one looks down a column, keeps only the rows that match a condition you give it, and then counts, adds or averages them. They're SUM, COUNT and AVERAGE from earlier lessons with a filter built in. This lesson shows all three on the same sales list, then moves on to conditions with operators, wildcards and dates, and to the -IFS versions that check several conditions at once.
The sales list we'll use
Every example in this lesson uses the same ten sales. Dates are in column A, the rep in B, the region in C, the product in D and the amount in E. The four East sales are shaded.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Date | Rep | Region | Product | Amount |
| 2 | 12/15/2025 | Ann | East | Desk | $450.00 |
| 3 | 1/5/2026 | Ben | West | Chair | $120.00 |
| 4 | 1/12/2026 | Ann | East | Office chair | $210.00 |
| 5 | 1/20/2026 | Cara | North | Desk lamp | $60.00 |
| 6 | 2/2/2026 | Ben | East | Desk | $480.00 |
| 7 | 2/9/2026 | Dev | West | Chair | $95.00 |
| 8 | 2/16/2026 | Cara | North | Office chair | $230.00 |
| 9 | 3/3/2026 | Ann | West | Desk lamp | $55.00 |
| 10 | 3/10/2026 | Dev | East | Chair | $130.00 |
| 11 | 3/24/2026 | Ben | North | Desk | $500.00 |
All three functions share the same two key arguments:
- range is the column Excel checks, for example the regions in
C2:C11. - criteria is the condition, for example
"East".
SUMIF and AVERAGEIF take a third, optional argument for the column of numbers to add or average. Leave it out and Excel uses the range itself, which is handy when the condition is about the numbers.
COUNTIF, SUMIF and AVERAGEIF with one condition
Here's how to get the number of East sales, their total and their average on Windows:
- Click B14 (the first yellow answer cell in the practice workbook).
- Type
=COUNTIF(C2:C11,"East")and press Enter. The answer is 4. - In B15, type
=SUMIF(C2:C11,"East",E2:E11)and press Enter. The answer is $1,270.00: 450 + 210 + 480 + 130. - In B16, type
=AVERAGEIF(C2:C11,"East",E2:E11)and press Enter. The answer is $317.50, which is 1,270 divided by 4.
On a Mac, press Return instead of Enter. Excel for the web works the same way, and all three functions are available in every current version of Excel, including Microsoft 365 on Windows and Mac and Excel for the web.
Read SUMIF as "look in C2:C11, find the cells that say East, and add the matching amounts from E2:E11". The range and the sum range should be the same size and shape. If they aren't, Excel quietly resizes the sum range to match, starting from its first cell, which can give a wrong total with no warning.
Text matching isn't case-sensitive: "east", "East" and "EAST" all count the same four cells. It is fussy about spaces, though. A cell that says "East " with a space on the end won't match "East", and nothing on screen tells you why the count is one short.
| A | B | |
|---|---|---|
| 13 | Question | Answer |
| 14 | 1. Number of East sales | 4 |
| 15 | 2. Total of East sales | $1,270.00 |
| 16 | 3. Average East sale | $317.50 |
| 17 | 4. Total of sales over $100 | $2,120.00 |
| 18 | 5. Total of sales not in East | $1,060.00 |
| 19 | 6. Number of sales over the amount in H1 | 5 |
Conditions with operators
The criteria can use any of the comparison operators from IF and IFS. Put the operator and the value inside the quotes together:
=SUMIF(E2:E11,">100")adds every amount over 100. There's no sum range here because the condition is about the amounts themselves. Answer: $2,120.00 (everything except the $60, $95 and $55 sales).=SUMIF(C2:C11,"<>East",E2:E11)adds everything that is not East: $1,060.00.=COUNTIF(E2:E11,">=500")counts sales of $500 or more: 1.- A plain number needs no quotes:
=COUNTIF(E2:E11,450)counts the cells equal to 450. - Two quotes with nothing between them,
"", match empty cells. If some sales had no region filled in,=SUMIF(C2:C11,"",E2:E11)would total just those, which is a quick way to find rows someone forgot to finish.
Using a criteria cell
Typing the number into the formula means editing it every time it changes. It's better to keep it in a cell. In the practice workbook, H1 holds 200. To count sales over that amount:
=COUNTIF(E2:E11,">"&H1)
The operator stays in quotes, and the & (ampersand) joins it to the cell, so Excel builds the condition ">200". The answer is 5. Change H1 to 100 and the answer becomes 7 straight away. Don't write ">H1": inside quotes, H1 is just two letters, not a cell.
Wildcards: partial matches
Sometimes you want to match part of a word. Criteria can use two wildcards:
*(asterisk) stands for any number of characters, including none.?(question mark) stands for exactly one character.
So =SUMIF(D2:D11,"*chair*",E2:E11) adds every product with "chair" anywhere in its name, both "Chair" and "Office chair": $785.00. "Desk*" matches Desk and Desk lamp ($1,545.00), and "Desk" on its own matches only Desk. A pattern like "B??" would match any three-letter entry starting with B, such as Ben.
What if the text you're searching for really contains an asterisk or a question mark, like a product called "Size?" Put a tilde (~) in front of it: "Size~?" finds the actual question mark rather than treating it as a wildcard.
Conditions with dates
Dates are numbers underneath (see Dates and times), so they work with the same operators. The safest way to write a date in a condition is with the DATE function, which avoids any confusion over day/month order:
=SUMIF(A2:A11,">="&DATE(2026,1,1),E2:E11)
That adds every sale on or after January 1, 2026: $1,880.00, which is everything except the December sale. As with a criteria cell, the operator is in quotes and joined with &.
You can also point at a date typed in a cell. H2 in the practice workbook holds 2/1/2026, so =SUMIF(A2:A11,">="&H2,E2:E11) adds everything from February 1 on: $1,490.00. Change H2 and the total follows.
Multiple conditions: COUNTIFS, SUMIFS, AVERAGEIFS
To check more than one thing, such as East sales by Ann, add an S. COUNTIFS, SUMIFS and AVERAGEIFS take pairs of range and criteria, up to 127 pairs, and a row only counts when all the conditions are true (AND logic).
Watch the argument order. In SUMIFS and AVERAGEIFS, the numbers to add or average come first, not last:
=SUMIF(C2:C11,"East",E2:E11)puts the sum range last.=SUMIFS(E2:E11,C2:C11,"East",B2:B11,"Ann")puts the sum range first.
Steps for the SUMIFS version:
- Click B23.
- Type
=SUMIFS(E2:E11,for the amounts to add. - Type
C2:C11,"East",for the first range and condition. - Type
B2:B11,"Ann")for the second range and condition, then press Enter.
| A | B | |
|---|---|---|
| 23 | 10. Ann's East total (SUMIFS) | $660.00 |
| 24 | 11. East OR West total | $1,540.00 |
| 25 | 12. Average South sale (no matches) | #DIV/0! |
| 26 | 13. Biggest East sale (MAXIFS) | $480.00 |
COUNTIFS has no separate number column, so it's just pairs: =COUNTIFS(C2:C11,"East",E2:E11,">200") counts East sales over $200, which gives 3. Each range must be the same size as the others. For a date range, use the date column twice: =SUMIFS(E2:E11,A2:A11,">="&DATE(2026,1,1),A2:A11,"<"&DATE(2026,2,1)) totals January: $390.00.
OR logic: add two SUMIFs
SUMIFS can't do "East or West", because one cell can't be both. Instead, add two SUMIFs:
=SUMIF(C2:C11,"East",E2:E11)+SUMIF(C2:C11,"West",E2:E11)
That's 1,270 + 270 = $1,540.00. The same trick works with COUNTIF. Only do this when the two conditions can't both be true for the same row; otherwise that row gets counted twice.
MAXIFS and MINIFS
Two newer cousins find the largest or smallest value that matches. Like SUMIFS, the number column comes first:
=MAXIFS(E2:E11,C2:C11,"East")gives the biggest East sale: $480.00.=MINIFS(E2:E11,C2:C11,"East")gives the smallest: $130.00.
If nothing matches, MAXIFS returns 0. Both need Excel 2019 or later, Microsoft 365 on Windows or Mac, or Excel for the web.
Try it yourself
Download the practice workbook and open the Practice sheet. The yellow cells in column B are for your answers.
- In B14, B15 and B16, count, total and average the East sales with COUNTIF, SUMIF and AVERAGEIF. Expect 4, $1,270.00 and $317.50.
- In B17, total the sales over $100 ($2,120.00). In B18, total everything not in East ($1,060.00).
- In B19, type
=COUNTIF(E2:E11,">"&H1)(5), then change H1 to 100 and watch it update. - In B20, use
"*chair*"to total every chair ($785.00). - In B21 and B22, total sales since
DATE(2026,1,1)($1,880.00) and since the date in H2 ($1,490.00). - In B23, use SUMIFS for Ann's East total ($660.00). In B24, add two SUMIFs for East or West ($1,540.00).
- In B25, average the South sales and see #DIV/0!. In B26, find the biggest East sale with MAXIFS ($480.00).
Check everything against the Answers sheet.
Common mistakes
- Mixing up SUMIF and SUMIFS order. Changing SUMIF to SUMIFS without moving the sum range to the front gives a wrong answer or an error.
- Forgetting the quotes. Criteria with an operator or text, like
">100"or"East", must be in double quotes. Plain numbers don't need them. - Putting a cell inside the quotes.
">H1"looks for the text H1. Use">"&H1. - Ranges of different sizes.
C2:C11withE2:E10won't line up. Keep every range the same rows. - #DIV/0! from AVERAGEIF. No row matched, often because of a typo or an extra space in the data. Fix the criteria, or wrap it in IFERROR:
=IFERROR(AVERAGEIF(C2:C11,"South",E2:E11),"None"). - Long text criteria. Microsoft warns that matching text longer than 255 characters gives wrong results. Keep criteria short, or match part of it with a wildcard.
- Numbers stored as text. SUMIF skips them, just like SUM. See the text trap in Add and SUM.
- Using SUMIFS for OR. All its conditions must be true at once, so "East" and "West" together gives 0.
What's next
You can now count, add and average just the rows you care about. Before this, IF and IFS showed how one cell makes a decision; next, Text functions shows how to clean up and split text, which helps when your criteria won't match because of stray spaces. For a refresher on plain averages, see Average, MIN, MAX and COUNT, or go back to the full Excel course. Pivot tables will later do this kind of summary with no formulas at all.
Frequently asked questions
What is the difference between SUMIF and SUMIFS?
SUMIF checks one condition; SUMIFS can check up to 127 at once, and a row is added only when all of them are true. The arguments are in a different order too: SUMIF is =SUMIF(range, criteria, sum_range) with the numbers to add last, while SUMIFS is =SUMIFS(sum_range, criteria_range1, criteria1, ...) with the numbers to add first.
Is SUMIF case-sensitive?
No. COUNTIF, SUMIF and AVERAGEIF ignore capital letters, so "east", "East" and "EAST" all match the same cells.
How do I use a cell reference with greater than in SUMIF?
Put the operator in quotes and join it to the cell with an ampersand: =SUMIF(E2:E11,">"&H1). Writing ">H1" inside the quotes doesn't work, because Excel then looks for the text H1 instead of the number in that cell.
How do I use SUMIF with dates?
Join a comparison to a date: =SUMIF(A2:A11,">="&DATE(2026,1,1),E2:E11) adds everything from January 1, 2026 on. You can also point at a date in a cell, like ">="&H2. For a date range (between two dates), use SUMIFS with two conditions on the same date column.
How do I do SUMIF with OR (this value or that value)?
Add two SUMIFs together: =SUMIF(C2:C11,"East",E2:E11)+SUMIF(C2:C11,"West",E2:E11). SUMIFS can't do this on its own, because all its conditions must be true at the same time.
Why does AVERAGEIF return #DIV/0!?
No cell matched your condition, so there is nothing to average. Check the spelling of the criteria, or wrap the formula in IFERROR to show a message instead, as explained in IF and IFS.