Nishaglobal Education logo

Counting and adding with conditions: COUNTIFS and SUMIFS

Answer everyday business questions in one formula: count matching rows with COUNTIF and COUNTIFS, add up matching values with SUMIF and SUMIFS, and find conditional averages with AVERAGEIF and AVERAGEIFS.

Lesson 5 of 1235 minQuiz: 4 questions

🎯 By the end of this lesson you will be able to:

  • Count rows that match one or more conditions
  • Add up and average values for rows that match conditions
  • Use cell references and comparison operators in criteria
Outline
  1. What you'll learn and why it matters
  2. COUNTIF and COUNTIFS: how many?
  3. SUMIF and SUMIFS: how much?
  4. Let people change the question
  5. Practice
  6. Common mistakes
  7. Recap
  8. Quiz
  9. Mark lesson complete

What you'll learn and why it matters

*How many orders did the North region place? What were Asha's total sales? What is the average order value for backpacks?* Managers ask questions like these all day. COUNTIFS and SUMIFS answer them in one formula each, and they update the moment new data is added.

COUNTIF and COUNTIFS: how many?

=COUNTIF(range, criteria) counts the cells in a range that match. COUNTIFS takes several *range, criteria* pairs and counts rows where all match:

Worksheet: Sales

The first ten orders with a summary in columns H and I. Each answer is one formula over the whole range.
RowABCDEFGHI
1RegionSalespersonProductUnitsPriceTotalQuestionAnswer
2WestAshaSketchbook113003300Orders from North4
3NorthMeeraPen set42501000Orders by Meera3
4WestRaviSketchbook3300900North orders by Meera2
5NorthSaraNotebook91201080Orders of 5+ units5
6EastRaviNotebook2120240
7NorthMeeraPen set82502000
8EastMeeraBackpack215003000
9NorthAshaDesk lamp412004800
10SouthKofiNotebook111201320
11WestRaviWater bottle104004000

Formulas (green cells)

  • F2 =D2*E2 → 3300
  • I2 =COUNTIF(A2:A11,"North") → 4
  • F3 =D3*E3 → 1000
  • I3 =COUNTIF(B2:B11,"Meera") → 3
  • F4 =D4*E4 → 900
  • I4 =COUNTIFS(A2:A11,"North",B2:B11,"Meera") → 2
  • F5 =D5*E5 → 1080
  • I5 =COUNTIF(D2:D11,">=5") → 5
  • F6 =D6*E6 → 240
  • F7 =D7*E7 → 2000
  • F8 =D8*E8 → 3000
  • F9 =D9*E9 → 4800
  • F10 =D10*E10 → 1320
  • F11 =D11*E11 → 4000
The first ten orders with a summary in columns H and I. Each answer is one formula over the whole range.
CriteriaMatches
"North"Cells equal to North (not case-sensitive)
">=5"Numbers of 5 or more (comparisons go inside the quotes)
"<>West"Everything except West
"*lamp*"Text containing lamp (* means any characters)
H2 or ">="&H2A value typed in another cell, so the question can change

SUMIF and SUMIFS: how much?

=SUMIFS(sum_range, criteria_range1, criteria1, …) adds up the values in sum_range for the rows that match. Note the order: the column to add comes first.

Worksheet: Sales

SUMIFS adds the Total (or Units) column for matching rows; AVERAGEIF gives the average of the matching rows (AVERAGEIFS does the same with several conditions).
RowABCDEFGHI
1RegionSalespersonProductUnitsPriceTotalQuestionAnswer
2WestAshaSketchbook113003300Total sales21640
3NorthMeeraPen set42501000Sales in North8880
4WestRaviSketchbook3300900Asha's sales8100
5NorthSaraNotebook91201080Notebook units22
6EastRaviNotebook2120240Avg Pen set order1500
7NorthMeeraPen set82502000
8EastMeeraBackpack215003000
9NorthAshaDesk lamp412004800
10SouthKofiNotebook111201320
11WestRaviWater bottle104004000

Formulas (green cells)

  • F2 =D2*E2 → 3300
  • I2 =SUM(F2:F11) → 21640
  • F3 =D3*E3 → 1000
  • I3 =SUMIFS(F2:F11,A2:A11,"North") → 8880
  • F4 =D4*E4 → 900
  • I4 =SUMIFS(F2:F11,B2:B11,"Asha") → 8100
  • F5 =D5*E5 → 1080
  • I5 =SUMIFS(D2:D11,C2:C11,"Notebook") → 22
  • F6 =D6*E6 → 240
  • I6 =AVERAGEIF(C2:C11,"Pen set",F2:F11) → 1500
  • F7 =D7*E7 → 2000
  • F8 =D8*E8 → 3000
  • F9 =D9*E9 → 4800
  • F10 =D10*E10 → 1320
  • F11 =D11*E11 → 4000
SUMIFS adds the Total (or Units) column for matching rows; AVERAGEIF gives the average of the matching rows (AVERAGEIFS does the same with several conditions).

Let people change the question

Put the criteria in cells and refer to them. Now anyone can type a different region or salesperson and the answer updates:

Worksheet: Sales

I1 and I2 hold the question; I3 and I4 answer it. Type South in I1 and both answers change.
RowABCDEFGHI
1RegionSalespersonProductUnitsPriceTotalRegionNorth
2WestAshaSketchbook113003300SalespersonMeera
3NorthMeeraPen set42501000Orders2
4WestRaviSketchbook3300900Sales3000
5NorthSaraNotebook91201080
6EastRaviNotebook2120240
7NorthMeeraPen set82502000
8EastMeeraBackpack215003000
9NorthAshaDesk lamp412004800
10SouthKofiNotebook111201320
11WestRaviWater bottle104004000

Formulas (green cells)

  • F2 =D2*E2 → 3300
  • F3 =D3*E3 → 1000
  • I3 =COUNTIFS(A2:A11,I1,B2:B11,I2) → 2
  • F4 =D4*E4 → 900
  • I4 =SUMIFS(F2:F11,A2:A11,I1,B2:B11,I2) → 3000
  • F5 =D5*E5 → 1080
  • F6 =D6*E6 → 240
  • F7 =D7*E7 → 2000
  • F8 =D8*E8 → 3000
  • F9 =D9*E9 → 4800
  • F10 =D10*E10 → 1320
  • F11 =D11*E11 → 4000
I1 and I2 hold the question; I3 and I4 answer it. Type South in I1 and both answers change.

Practice

Guided exercise

Regional report

In the ten orders, count the orders from West and add up West's total sales.

  1. Count: =COUNTIF(A2:A11,"West").
  2. Sum: =SUMIFS(F2:F11,A2:A11,"West") (the Total column first).
Show the solution

Worksheet: Sales

RowABCDEFGHI
1RegionSalespersonProductUnitsPriceTotalQuestionAnswer
2WestAshaSketchbook113003300West orders3
3NorthMeeraPen set42501000West sales8200
4WestRaviSketchbook3300900
5NorthSaraNotebook91201080
6EastRaviNotebook2120240
7NorthMeeraPen set82502000
8EastMeeraBackpack215003000
9NorthAshaDesk lamp412004800
10SouthKofiNotebook111201320
11WestRaviWater bottle104004000

Formulas (green cells)

  • F2 =D2*E2 → 3300
  • I2 =COUNTIF(A2:A11,"West") → 3
  • F3 =D3*E3 → 1000
  • I3 =SUMIFS(F2:F11,A2:A11,"West") → 8200
  • F4 =D4*E4 → 900
  • F5 =D5*E5 → 1080
  • F6 =D6*E6 → 240
  • F7 =D7*E7 → 2000
  • F8 =D8*E8 → 3000
  • F9 =D9*E9 → 4800
  • F10 =D10*E10 → 1320
  • F11 =D11*E11 → 4000

How to get there: COUNTIF counts the matching rows; SUMIFS adds the Total column for those same rows. Checking by eye against the list is a good habit while you learn.

Your turn

Big orders

How many orders have a total of 2,000 or more, and what do they add up to?

Show the solution

Worksheet: Sales

RowABCDEFGHI
1RegionSalespersonProductUnitsPriceTotalQuestionAnswer
2WestAshaSketchbook113003300Orders ≥ 20005
3NorthMeeraPen set42501000Their total17100
4WestRaviSketchbook3300900
5NorthSaraNotebook91201080
6EastRaviNotebook2120240
7NorthMeeraPen set82502000
8EastMeeraBackpack215003000
9NorthAshaDesk lamp412004800
10SouthKofiNotebook111201320
11WestRaviWater bottle104004000

Formulas (green cells)

  • F2 =D2*E2 → 3300
  • I2 =COUNTIF(F2:F11,">=2000") → 5
  • F3 =D3*E3 → 1000
  • I3 =SUMIFS(F2:F11,F2:F11,">=2000") → 17100
  • F4 =D4*E4 → 900
  • F5 =D5*E5 → 1080
  • F6 =D6*E6 → 240
  • F7 =D7*E7 → 2000
  • F8 =D8*E8 → 3000
  • F9 =D9*E9 → 4800
  • F10 =D10*E10 → 1320
  • F11 =D11*E11 → 4000

How to get there: The criteria range and the sum range can be the same column. The comparison goes inside quotes: ">=2000".

Common mistakes

Putting the sum range last in SUMIFS

You see: Wrong totals or an error

Fix: SUMIFS: sum range first, then criteria pairs.

Ranges of different sizes

You see: #VALUE!

Fix: Every range must cover the same rows, such as 2 to 11.

Writing >=5 without quotes

You see: Excel reports a formula error

Fix: Put comparisons in quotes: ">=5".

Extra spaces in the data, like North

You see: Rows that look matching are not counted

Fix: Clean the data with TRIM (lesson 7).

Recap

  • COUNTIF counts matching cells; COUNTIFS counts rows matching every condition.
  • SUMIFS(sum_range, range1, criteria1, …) adds values for matching rows; AVERAGEIF and AVERAGEIFS average them.
  • Criteria can be text, comparisons in quotes like ">=5", wildcards, or cell references.
  • Referring to criteria cells turns a formula into a reusable report.

Key terms

Criteria
The condition a cell must meet to be counted or added, such as "North" or ">=5".
Sum range
The column of numbers SUMIFS adds up for the matching rows.
Wildcard
* (any characters) or ? (one character) in text criteria.

Check your understanding

Answer all 4 questions, then check your answers to see an explanation for each one.

  1. 1. Which formula adds up column F for rows where column A is South?

  2. 2. How do you count values of 100 or more in B2:B50?

  3. 3. What does COUNTIFS count?

  4. 4. Why put criteria like a region name in its own cell?

Answer all 4 questions to check.

Mark this lesson complete

Finished this lesson?

When you have worked through the examples and exercises, mark it complete to save your progress.