Find a course

Module 3: Conditional Math and Business CalculationsLesson 6 of 1213 min

COUNTIFS, SUMIFS and AVERAGEIFS

Answer questions like "how much did the West region sell over $500?" with conditional counts, sums and averages using operators, cells and wildcards.

Step 1 of 11Learn

Questions a filter can answer once

A sales manager has a table of 4,000 orders and three questions before a 10 a.m. meeting: How many West orders were over $500? What did Ana sell in total? What's the average order in the West?

She could filter the table three times and read the status bar. That works once. Next week the data changes and she does it all again, with no record of what she filtered. Conditional aggregation functions answer the same questions with formulas that update themselves:

  • COUNTIFS counts rows that meet every condition.
  • SUMIFS adds up a column for rows that meet every condition.
  • AVERAGEIFS averages a column for those rows.
  • MAXIFS and MINIFS find the largest and smallest values among them.

We'll use this small table throughout the lesson. Imagine Region in column B, Rep in C and Amount in D, rows 2 to 7:

OrderRegionRepAmount
1001WestAna820
1002EastBen430
1003WestAna310
1004WestCho1,250
1005EastAna990
1006WestBen505

The same formulas work identically on 4,000 rows or 400,000.

The sample order table used in this lessonRowA: OrderB: RegionC: RepD: Amount21001WestAna82031002EastBen43041003WestAna31051004WestCho1,25061005EastAna99071006WestBen505

Step 2 of 11Learn

COUNTIFS and how criteria work

COUNTIFS takes pairs of arguments: a range to check, then the condition for that range.

=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)

To count West orders over $500:

=COUNTIFS(B2:B7, "West", D2:D7, ">500")

Every pair must be satisfied, so multiple conditions are combined with AND logic. All ranges must be the same size, or you get #VALUE!.

Criteria are written as text, which trips people up. An exact match is just the value: "West" or 1001. A comparison puts the operator inside the quotes: ">500", "<=100", "<>East" (not East).

When the threshold lives in a cell, say F1, you can't write ">F1", because that's a comparison with the literal text F1. Instead, join the operator to the cell with &:

=COUNTIFS(D2:D7, ">"&F1)

The single-condition version, COUNTIF(range, criteria), still works, but since COUNTIFS handles one condition just as well, many people use the plural form everywhere.

Step 3 of 11Practice · Work it out

Using the order table, what does =COUNTIFS(B2:B7, "West", D2:D7, ">500") return?

Step 4 of 11Learn

SUMIFS, AVERAGEIFS and the argument-order trap

SUMIFS and AVERAGEIFS add one argument at the front: the range to sum or average.

=SUMIFS(sum_range, criteria_range1, criteria1, ...)

Ana's total sales:

=SUMIFS(D2:D7, C2:C7, "Ana") returns 820 + 310 + 990 = 2,120.

Average West order:

=AVERAGEIFS(D2:D7, B2:B7, "West") returns (820 + 310 + 1,250 + 505) / 4 = 721.25.

Largest East order: =MAXIFS(D2:D7, B2:B7, "East") returns 990.

Now the trap. The older single-condition SUMIF puts the sum range last:

=SUMIF(C2:C7, "Ana", D2:D7)

People who learned SUMIF first often write SUMIFS in the old order. Excel then tries to sum the Rep column (which is text, so it returns 0) or returns #VALUE!. If a conditional sum comes back as 0 when you know there's data, check the argument order first.

One more caution: AVERAGEIFS returns #DIV/0! when no rows match, since it would be dividing by zero rows.

SUMIFS(D2:D7, C2:C7, "Ana") adds only the highlighted rows: 820 + 310 + 990 = 2,120RowA: OrderB: RegionC: RepD: Amount21001WestAna82031002EastBen43041003WestAna31051004WestCho1,25061005EastAna99071006WestBen505

Step 5 of 11Compare

SUMIF vs SUMIFS: the argument-order trap

AspectSUMIFSUMIFS
SyntaxSUMIF(range, criteria, [sum_range])SUMIFS(sum_range, range1, criteria1, ...)
Where the sum range goesLastFirst
Ana's total=SUMIF(C2:C7, "Ana", D2:D7)=SUMIFS(D2:D7, C2:C7, "Ana")
Number of conditionsOneOne or many (AND logic)
Symptom of mixing them upWrong totalResult of 0 or #VALUE!

Step 6 of 11Practice · Choose one

Which formula correctly totals the Amount column (D) for East orders by Ben?

Step 7 of 11Learn

Wildcards, blanks and date ranges

Text criteria can include wildcards:

  • * matches any number of characters: "*phone*" matches "Smartphone", "phone case" and "Headphones".
  • ? matches exactly one character: "A-??" matches "A-10" and "A-7B" but not "A-100".
  • ~ escapes a real asterisk or question mark: "~*" matches an actual *.

Wildcards only work on text. They don't match numbers stored as numbers.

To test for empty or non-empty cells: "" matches blank cells and "<>" matches cells that aren't blank. =COUNTIFS(E2:E500, "<>") counts rows where a ship date has been entered.

Date ranges use two conditions on the same column. Sales in March 2026, with start and end dates in H1 and H2:

=SUMIFS(D:D, A:A, ">="&H1, A:A, "<="&H2)

Putting the dates in cells beats typing them into the formula: ">=3/1/2026" depends on regional date settings, while a real date in a cell always works. Better still, use ">="&H1, "<"&EDATE(H1,1), which captures the whole month even when times are attached to the dates.

Step 8 of 11Practice · Match the pairs

Match each criteria argument to what it matches.

Tap an answer, then tap the place where it belongs (or drag it there).

  1. ">=100"
  2. "<>Closed"
  3. "tea"
  4. "<>"
  5. ">"&F1

Step 9 of 11Note

Step 10 of 11Practice · Work it out

Using the order table, what does =AVERAGEIFS(D2:D7, C2:C7, "Ana", B2:B7, "West") return?

Step 11 of 11Practice · Spot the mistake

This formula should total column D for West orders at or above the threshold in F1, but it returns 0. Click the faulty argument.