Sub topic 13
SUMIF, COUNTIF, and AVERAGEIF: how they differ
What this chapter covers
This chapter assumes you can already write SUMIFS, COUNTIFS, and AVERAGEIFS with one or more criteria pairs. It covers their older single-condition relatives: SUMIF, COUNTIF, and AVERAGEIF.
You will meet these functions in older spreadsheets, in tutorials, and in formulas other people wrote. They look almost identical to the plural versions, but their argument order is different. That difference causes most of the errors people make when they edit or copy these formulas.
The examples use one sample sheet. Rows 2 to 100 hold data:
| Column | Content |
|---|---|
| A | Region |
| B | Product |
| C | Date |
| D | Units |
| E | Revenue |
The three single-condition functions
Each function takes one range to test and one criterion. The criterion uses the same rules as in the plural functions: comparison operators, wildcards, and & concatenation all work. Text matching is still not case-sensitive.
=COUNTIF(A2:A100, "West")=SUMIF(A2:A100, "West", E2:E100)=AVERAGEIF(A2:A100, "West", E2:E100)Read them in plain language:
- COUNTIF counts the rows where column A equals "West".
- SUMIF looks in column A for "West" and adds the matching values from column E.
- AVERAGEIF looks in column A for "West" and averages the matching values from column E.
The signatures are:
| Function | Signature |
|---|---|
| COUNTIF | `COUNTIF(range, criterion)` |
| SUMIF | `SUMIF(range, criterion, [sum_range])` |
| AVERAGEIF | `AVERAGEIF(range, criterion, [average_range])` |
The square brackets mean the argument is optional.
The argument order flips
This is the main difference between the two families. In the plural functions, the range to add or average comes first. In the singular functions, it comes last.
| Task | Single condition | Plural version |
|---|---|---|
| Sum Revenue where Region is West | `=SUMIF(A2:A100, "West", E2:E100)` | `=SUMIFS(E2:E100, A2:A100, "West")` |
| Average Revenue where Region is West | `=AVERAGEIF(A2:A100, "West", E2:E100)` | `=AVERAGEIFS(E2:E100, A2:A100, "West")` |
| Count rows where Region is West | `=COUNTIF(A2:A100, "West")` | `=COUNTIFS(A2:A100, "West")` |
COUNTIF and COUNTIFS look the same for one condition because neither has a value range to place. SUMIF and AVERAGEIF are the risky pair.
If you swap the order by mistake, Sheets may return an error or a wrong number. Here is a typical mistake:
=SUMIF(E2:E100, A2:A100, "West")This formula puts the sum range first, which is the SUMIFS order, so it does not do what you intended. The corrected single-condition form is =SUMIF(A2:A100, "West", E2:E100).
The optional third argument
SUMIF and AVERAGEIF let you leave out the third argument. When you do, the function tests the range and also sums or averages that same range. This is useful when the condition and the numbers live in one column.
=SUMIF(D2:D100, ">=10")This adds up the Units values that are at least 10. The range being tested and the range being summed are both D2:D100.
=AVERAGEIF(E2:E100, ">0")This averages the Revenue values that are greater than zero. It is a quick way to ignore zeros and negative refunds.
The plural functions have no such shortcut. SUMIFS and AVERAGEIFS always require the sum or average range as the first argument. To get the same result, repeat the range:
=SUMIFS(D2:D100, D2:D100, ">=10")The same column appears twice, once as the range to add and once as a criteria range.
Range sizes
The plural functions require every range to have the same number of rows and columns. A mismatch gives an error.
For SUMIF and AVERAGEIF, you should also keep the two ranges the same size. Do not write A2:A100 with E2:E50. Even if a spreadsheet application tolerates a difference, the result is hard to reason about and breaks silently when someone inserts rows. Treat equal sizes as a rule for all six functions.
What they cannot do
A single-condition function has exactly one range and one criterion. There is no way to add a second condition. To test Region and Units together, you must use the plural form:
=AVERAGEIFS(E2:E100, A2:A100, "West", D2:D100, ">=10")Everything else carries over unchanged:
- Operators such as
>,<=, and<>work the same way. - Building a criterion with
&, as in">"&H1, works the same way. - Wildcards
*and?work the same way. - AVERAGEIF returns
#DIV/0!when no row matches, exactly like AVERAGEIFS. Wrap it in IFERROR in the same way.
=IFERROR(AVERAGEIF($A$2:$A$100, G2, $E$2:$E$100), "No matches")Which one should you use?
SUMIFS, COUNTIFS, and AVERAGEIFS can do everything the singular functions do, plus multiple conditions. Many people therefore use only the plural forms. This has one real benefit: you learn one argument order, and adding a second condition later means appending a pair rather than rewriting the formula.
Use the singular forms when:
- You are reading or maintaining an existing sheet that uses them. Do not rewrite working formulas just for style.
- You want the shortcut of omitting the third argument for a one-column condition.
- The formula is short and has one condition that will not change.
Common errors
- Reversed order. Writing
=SUMIF(E2:E100, A2:A100, "West"). Check that the criterion is the second argument. - Adding a second condition to a singular function. SUMIF accepts only one range and one criterion. Extra arguments do not become more conditions. Switch to SUMIFS.
- Copying a plural formula pattern into a singular function. For example,
=AVERAGEIF(E2:E100, A2:A100, "West")places the value range first. - Forgetting
#DIV/0!handling. AVERAGEIF fails on no matches, while SUMIF returns 0 and COUNTIF returns 0. - Mismatched range sizes. Keep the criteria range and the value range the same height.
Summary of differences
| Feature | Singular (`...IF`) | Plural (`...IFS`) |
|---|---|---|
| Number of conditions | One | One or more |
| Value range position | Last, and optional | First, and required |
| Omit the value range | Allowed | Not allowed |
| COUNT variant | `COUNTIF(range, criterion)` | `COUNTIFS(range1, criterion1, ...)` |
| No match, AVERAGE variant | `#DIV/0!` | `#DIV/0!` |
| No match, SUM and COUNT variants | 0 | 0 |
Exercise
A colleague wrote =SUMIF(E2:E100, "West", A2:A100) to add Revenue for the West region. Why is it wrong, and what is the corrected formula? Then write the SUMIFS equivalent.
Show answer
In SUMIF the order is range, criterion, sum_range. The colleague put the Revenue column first, so Sheets tests the Revenue values against "West" and then tries to sum the Region column. Correct formula: =SUMIF(A2:A100, "West", E2:E100). The SUMIFS equivalent puts the sum range first: =SUMIFS(E2:E100, A2:A100, "West").
Exercise
Write one formula using a singular function that averages only the Units values (D2:D100) that are at least 10. Then write the same result with AVERAGEIFS.
Show answer
Singular: =AVERAGEIF(D2:D100, ">=10"). The third argument is omitted, so the Units range is both tested and averaged. Plural: =AVERAGEIFS(D2:D100, D2:D100, ">=10"). The plural form must name the average range first and then repeat it as the criteria range.