
Step 1 of 8
Choose a Count or a Total
Choose whether a category question needs a matching-record count or a matching-amount total, then create the Sales worksheet used throughout the tutorial.
Learning path · Level 4 · Tutorial 5
Calculate category sales totals and matching-record counts with SUMIF and COUNTIF in Excel or Calc. Use text and numeric criteria, keep ranges aligned when copying formulas, and check the results against the underlying records without relying on visible filter results.
Choose a Count or a Total
Choose whether a category question needs a matching-record count or a matching-amount total, then create the Sales worksheet used throughout the tutorial. 2 min
Count Records for a Category
Count matching category records with COUNTIF, using both quoted text and a category-summary cell reference. 2 min
Total Amounts from Matching Rows
Build a category SUMIF formula and keep criteria and amount ranges aligned so matching source records contribute the correct sales amounts. 3 min
Use Numeric Conditions
Count and total source-record amounts using literal numeric criteria, then compare inclusive and strict boundaries. 2 min
Control the Condition from a Cell
Replace a hard-coded numeric comparison with a criterion built from an operator and the threshold in H2. 2 min
Copy a Reliable Category Summary
Anchor COUNTIF and SUMIF source ranges so a category summary can be copied down reliably. 3 min
Test Missing Matches and Filtered Rows
Test zero-result cases and confirm that conditional formulas still evaluate all referenced source records when a worksheet filter hides some rows. 2 min
Reconcile and Verify the Summary
Complete a final audit of the category summary by reconciling counts and amounts with the source records. 3 min

Step 1 of 8
Choose whether a category question needs a matching-record count or a matching-amount total, then create the Sales worksheet used throughout the tutorial.
A conditional summary starts by choosing the question.
For example, Stationery can appear in several source records. A count treats each matching row as one record; a total combines the amounts from those same matching rows. Later, you will build the formulas that produce these answers.

The same matching source records can answer two different questions: how many records match, and how much their amounts add up.
On your computer, create a new worksheet named Sales. Enter the following source records in cells A1:B10 exactly as shown. The header row is not a source record.
Enter the amounts as numbers without typed currency symbols. Format B2:B10 as US dollars with two decimal places if your application supports that format.
Enter these values in A1:B10 on the Sales worksheet.
| Row | Category | Amount (USD) |
|---|---|---|
| 1 | Category | Amount (USD) |
| 2 | Stationery | 40 |
| 3 | Accessories | 120 |
| 4 | Storage | 200 |
| 5 | Stationery | 100 |
| 6 | Accessories | 80 |
| 7 | Stationery | 50 |
| 8 | Storage | 150 |
| 9 | Accessories | 0 |
| 10 | Stationery | 60 |
Next, create a separate category summary in D1:F5. Leave the calculation cells empty for now. This layout keeps summary results separate from the source records.
Format future values in F2:F5 as US dollars with two decimal places. Counts in E2:E5 should be displayed as whole numbers.
Enter the labels and category names shown below. Do not change the source records while working through this tutorial.
| Cell | Enter | Purpose |
|---|---|---|
| D1 | Category | Summary header |
| E1 | Matching records | Summary header |
| F1 | Sales (USD) | Summary header |
| D2 | Stationery | Category to summarize |
| D3 | Accessories | Category to summarize |
| D4 | Storage | Category to summarize |
| D5 | All categories | Reserved total label |
Match each prompt or source-range description to the correct answer.
Tap an item and then its matching pair.

Step 2 of 8
Count matching category records with COUNTIF, using both quoted text and a category-summary cell reference.
A category may appear in several source records. COUNTIF answers how many records meet one condition; it does not add their amounts.
Its structure is COUNTIF(criteria range, criterion). For this worksheet, the criteria range is A2:A10, not A1:A10, so the Category header is excluded. Every source row whose category meets the criterion contributes one—regardless of whether its amount is positive, zero, or large.

For Stationery, source rows 2, 5, 7, and 10 each contribute one matching record.
Tip
A zero amount does not remove a source record from a category count. COUNTIF examines the selected criteria range, so a category record still counts even when its amount is 0.
A literal text criterion uses straight double quotation marks. To test Stationery, enter the comma version below in temporary practice cell H4.
If your Excel or Calc locale uses semicolons, use =COUNTIF(A2:A10;"Stationery") instead. The accepted separator depends on your application and locale settings.
Enter this formula in H4.
=COUNTIF(A2:A10,"Stationery")4
The result is a whole-number record count.
Example
The criterion selects the four Stationery source records. It does not inspect or total the corresponding values in column B; that is a different task.
A criterion can also be a cell reference. D2 already contains the category label Stationery, so enter the formula below in E2 of the category summary.
With a semicolon separator, use =COUNTIF(A2:A10;D2). This produces the same count while letting the category label live in the summary cell rather than inside the formula.
Enter this formula in E2.
=COUNTIF(A2:A10,D2)4
D2 contains Stationery, so the result is a whole-number count.
Finish the criteria in these two formulas. Then enter the completed formulas in the indicated worksheet cells.
Complete the missing criteria.
H4: =COUNTIF(A2:A10,)
E2: =COUNTIF(A2:A10,)In your worksheet, verify the count in both H4 and E2. Identify the four Stationery source-row numbers. Then use H5 to count Accessories with a literal category criterion. Report the Accessories count and explain why its zero amount does or does not change that count.
Write at least 60 characters (0/60).

Step 3 of 8
Build a category SUMIF formula and keep criteria and amount ranges aligned so matching source records contribute the correct sales amounts.
On the existing Sales worksheet, SUMIF answers a different question from COUNTIF: it adds the amounts contributed by matching source records.
Its three parts are:
In the category summary, D2 contains Stationery. Enter a SUMIF in F2 to add the Amount (USD) values for every source record whose Category matches D2.
In F2, enter this formula and format the result as US dollars with two decimal places.
=SUMIF(A2:A10,D2,B2:B10)$250.00
The displayed result assumes F2 is formatted as US currency with two decimal places.
Tip
In Calc configurations that use semicolons, use:
=SUMIF(A2:A10;D2;B2:B10)
The accepted separator depends on your application and locale settings. The criterion D2 selects the Stationery source records in column A; SUMIF then adds the amounts from the matching rows in column B.

Correct ranges begin and end on the same source-record rows. A shifted range can contain the same number of cells but pair records incorrectly.
SUMIF pairs positions row by row. With A2:A10 as the criteria range, the sum range must be B2:B10: row 2 is paired with row 2, through row 10 with row 10.
Do not judge alignment by range size alone. A2:A10 and B3:B11 both contain nine cells, but their first rows differ. That shift makes the Stationery test in A2 use the amount in B3, not B2.
This shifted formula is structurally wrong, even though it returns a number.
=SUMIF(A2:A10,D2,B3:B11)$350.00
The result is wrong because the amounts are shifted one row relative to the source categories. B11 is outside the source records and is blank.
Match each Stationery category cell to the amount cell from the same aligned source record.
Tap an item and then its matching pair.
In F2, repair the shifted-range formula. Use the range diagram to keep every tested category cell paired with the amount from the same source-record row. The completed formula must summarize Stationery and return $250.00.
=SUMIF(,D2,)
Step 4 of 8
Count and total source-record amounts using literal numeric criteria, then compare inclusive and strict boundaries.
Numeric conditions test the Amount (USD) source records, so the criteria range is B2:B10.
A bare numeric criterion tests equality: 100 means exactly 100. A comparison criterion combines an operator and a number inside straight double quotation marks: ">=100" means 100 or more.
The inclusive operator >= includes an amount on the boundary. The strict operator > excludes an amount exactly equal to the boundary.

An inclusive condition includes the amount that is exactly on its boundary.
Use the temporary practice cells consistently: H4 checks equality, H5:H6 check the inclusive condition, and H7:H8 check the strict condition. Enter one separator version only. Use the comma formulas if your application accepts commas; otherwise use the semicolon formulas. Format H6 and H8 as US dollars with two decimal places. Display H4, H5, and H7 as whole numbers.
Comma separator:
H4: =COUNTIF(B2:B10,100)
H5: =COUNTIF(B2:B10,">=100")
H6: =SUMIF(B2:B10,">=100",B2:B10)
H7: =COUNTIF(B2:B10,">100")
H8: =SUMIF(B2:B10,">100",B2:B10)
Semicolon equivalent — use instead if required by your locale:
H4: =COUNTIF(B2:B10;100)
H5: =COUNTIF(B2:B10;">=100")
H6: =SUMIF(B2:B10;">=100";B2:B10)
H7: =COUNTIF(B2:B10;">100")
H8: =SUMIF(B2:B10;">100";B2:B10)H4: 1 H5: 4 H6: $570.00 H7: 3 H8: $470.00
The monetary results assume US-dollar formatting with two decimal places. H4, H5, and H7 are counts.
Tip
In each SUMIF formula, B2:B10 is both the criteria range and the sum range. Each source-record amount is tested; an amount that meets the condition is also added. Using the same range for both roles keeps the tested amounts and added amounts aligned.
Compare the two boundary conditions after entering the formulas.
| Condition | Matching records | Sales (USD) |
|---|---|---|
| >=100 | 4 | $570.00 |
| >100 | 3 | $470.00 |
| =100 | 1 | $100.00 |
For the source records, which result belongs to the strict condition ">100"?
Complete the inclusive pair for amounts at least $100.00 and the strict pair for amounts greater than $100.00. Enter the completed formulas in H5:H8 on your Sales worksheet, using your application’s accepted separator, and verify the displayed count and total for each condition.
H5: =COUNTIF(B2:B10,"")
H6: =SUMIF(B2:B10,"",B2:B10)
H7: =COUNTIF(B2:B10,"")
H8: =SUMIF(B2:B10,"",B2:B10)
Step 5 of 8
Replace a hard-coded numeric comparison with a criterion built from an operator and the threshold in H2.
Use H2 as the control for a numeric condition instead of typing the threshold inside each formula. Enter Threshold (USD) in H1 and enter 100 in H2.
The & operator joins pieces of a criterion. Keep the comparison operator in straight double quotation marks, but leave the cell reference outside them:
">="&H2
When H2 contains 100, this constructs the criterion >=100. If you later change H2, the formulas use the new threshold automatically.

H2 supplies the changing number; the quoted operator and & create the criterion used by both functions.
Enter the first formula in H4 and the second in H5. Format H5 as US dollars with two decimal places.
The formulas below use commas. Calc installations or locales that use semicolons require the equivalent semicolon versions.
=COUNTIF(B2:B10,">="&H2)
=SUMIF(B2:B10,">="&H2,B2:B10)
=COUNTIF(B2:B10;">="&H2)
=SUMIF(B2:B10;">="&H2;B2:B10)H4: 4 H5: $570.00
The displayed results assume H2 contains 100. Formula separators depend on the application and locale settings.
Example
At a threshold of 100, the inclusive condition includes the amount exactly equal to 100. The qualifying amounts are 120, 200, 100, and 150, so H4 shows 4 and H5 shows $570.00.
Change only H2 to 150. The formulas do not need editing: H4 updates to 2, and H5 updates to $350.00. This happens because the criterion is rebuilt from the current value in H2.
After checking the update, restore H2 to 100 for the remaining practice.
Complete both criteria so the formulas use an inclusive threshold from H2.
=COUNTIF(B2:B10,)
=SUMIF(B2:B10,,B2:B10)On the Sales worksheet, enter threshold-driven COUNTIF and SUMIF formulas in H4 and H5 using B2:B10 and H2. First check the results with H2 set to 100. Then change H2 to 150 and check both updated results. Finally, restore H2 to 100.
Report the two formulas you entered, the count and sales total at each threshold, and confirm that H2 is restored.
Write at least 100 characters (0/100).

Step 6 of 8
Anchor COUNTIF and SUMIF source ranges so a category summary can be copied down reliably.
Your category summary already has category labels in D2:D4. When you copy its formulas down, the source records must stay on the same nine rows. Only the criterion cell should move from D2 to D3, then D4.
Use absolute references for the source ranges and a relative reference for the category criterion.
The source ranges remain fixed; the category criterion advances one summary row at a time.

The source ranges remain fixed; the category criterion advances one summary row at a time.
On the Sales worksheet, enter the count formula in E2 and the total formula in F2. The dollar signs lock both source ranges. D2 has no dollar signs because it must change when you fill the formulas down through row 4.
Use the comma version below only if your application accepts commas. If your Excel or Calc locale uses semicolons, use the semicolon version instead. Do not enter both versions or mix separators in one formula.
Enter one matching separator version in E2 and F2. Check the displayed results before filling down.
Comma separator:
E2: =COUNTIF($A$2:$A$10,D2)
F2: =SUMIF($A$2:$A$10,D2,$B$2:$B$10)
Semicolon separator:
E2: =COUNTIF($A$2:$A$10;D2)
F2: =SUMIF($A$2:$A$10;D2;$B$2:$B$10)E2: 4 F2: $250.00
Use only the comma formulas or only the semicolon formulas, according to your application and locale settings. F2 must be formatted as US dollars with two decimal places.
Example
Fill E2:F2 down through row 4. Then select F3 and inspect its formula in the formula bar. The criteria range and sum range should still begin at row 2 and end at row 10, while the criterion should now refer to the category in row 3.
If a source reference changed row, undo the fill, correct the missing dollar signs in row 2, and fill down again.
Complete the formula so its two source ranges remain fixed when copied down the category summary.
=SUMIF(,D2,)Complete the category summary on your own worksheet:
Report the three category results in E2:F4 and the formula displayed in F3.
Write at least 80 characters (0/80).

Step 7 of 8
Test zero-result cases and confirm that conditional formulas still evaluate all referenced source records when a worksheet filter hides some rows.
A $0.00 total can mean two different things. If the category is absent, both the matching-record count and the total are zero. If matching records exist but their amounts add to zero, the total is still $0.00, but the count is not zero.
Keep the source records unchanged. Use a count alongside a total whenever you need to tell these cases apart.

An absent category produces count 0 and total $0.00. The amount condition 0 finds one source record, yet its total is also $0.00.
Example
Use H4:H7 for these temporary checks:
=COUNTIF(A2:A10,"Services") → 0Calc separator variant: =COUNTIF(A2:A10;"Services")
=SUMIF(A2:A10,"Services",B2:B10) → $0.00Calc separator variant: =SUMIF(A2:A10;"Services";B2:B10)
=COUNTIF(B2:B10,0) → 1Calc separator variant: =COUNTIF(B2:B10;0)
=SUMIF(B2:B10,0,B2:B10) → $0.00Calc separator variant: =SUMIF(B2:B10;0;B2:B10)
Whether your application accepts commas or semicolons depends on its locale settings. Format total cells as US dollars with two decimal places and count cells as whole numbers.
Complete the criterion for the absent-category check.
=COUNTIF(A2:A10,"")A worksheet filter changes which source rows you can see; it does not change the cells referenced by COUNTIF or SUMIF. To test this clearly, place the outputs outside the filtered range.
In H12 enter:=COUNTIF(A2:A10,"Accessories")
Calc variant: =COUNTIF(A2:A10;"Accessories")
In H13 enter:=SUMIF(A2:A10,"Accessories",B2:B10)
Calc variant: =SUMIF(A2:A10;"Accessories";B2:B10)
H12 should display 3 and H13 should display $200.00. Format H13 as US dollars with two decimal places.

Filter A1:B10 to show Stationery only. The checks in H12:H13 remain visible and keep their Accessories results because their formulas still evaluate A2:A10 and B2:B10.
Tip
After entering the checks, filter A1:B10 so that only Stationery source records are visible. Do not use the visible rows as the basis for a new calculation: inspect H12 and H13 instead. Their values do not change. Clear the filter when the check is complete so the full source is ready for the final audit.
Perform one complete verification on your worksheet:
In your response, report the count and total for Services, the count and total for the amount condition 0, and the count and total shown by the filtered Accessories checks. Also confirm that you cleared the filter.
Write at least 100 characters (0/100).

Step 8 of 8
Complete a final audit of the category summary by reconciling counts and amounts with the source records.
A reliable category summary accounts for every source record once. In Sales, the three category rows in D2:D4—Stationery, Accessories, and Storage—are the complete set of source categories. D5 is a grand-total row, not another category.
Before the final audit, clear any worksheet filter. Then inspect the category formulas: each criteria range should cover A2:A10, each sum range should cover B2:B10, and each criterion should point to its category cell in column D. Formula inspection can catch an incorrect range even when a grand total looks plausible.

Each source record belongs to one category row, so the complete category summary can be checked against the full source.
Use these independent checkpoints after calculating the category summary. A known-match check confirms an individual category result; the Services test confirms that an absent criterion produces zeros.
| Check | Expected count | Expected amount |
|---|---|---|
| All source records | 9 | $800.00 |
| Stationery known match | 4 | $250.00 |
| Services no-match | 0 | $0.00 |
Complete the All categories row by adding the already calculated category-summary results—not by adding another conditional criterion.
Enter the count formula in E5 and the sales formula in F5. Independently check the amount by summing the source amount range. SUM has one range argument, so it is written the same way in Excel and Calc regardless of the separator used for multi-argument functions.
Format F5 as US dollars with two decimal places and keep E5 as a whole number.
Enter these formulas in the indicated cells.
E5: =SUM(E2:E4)
F5: =SUM(F2:F4)
Independent source-amount check:
=SUM(B2:B10)9 $800.00 $800.00
Displayed results, in the same order as the three entries: E5, F5, then the independent source-amount check.
Warning
Grand-total agreement is necessary, but it is not sufficient. A shifted criteria range or sum range can sometimes produce a believable total. Keep individual category checks, the Services no-match check, and formula inspection as part of the audit.
Fill the two range references so the All categories row totals the category summary.
E5: =SUM()
F5: =SUM()With the worksheet filter cleared, finish the audit in Sales. In 2–4 sentences, report:
=SUM(B2:B10), including the dollar result;Write at least 180 characters (0/180).
Congratulations! You completed: Summarize Matching Records with SUMIF and COUNTIF
You completed this level!
Up next: Analysis and Dashboards
Summarize Sales by Category and Month with Pivot TablesCreate sales summaries by category and month in Excel or LibreOffice Calc using a small register you enter yourself or an existing clean register. Choose suitable aggregations, verify totals, and distinguish refreshing existing records from including newly added rows.Thousands of online courses in video, ebooks and audiobooks.
To test your knowledge during online courses
Generated directly from your cell phone's photo gallery and sent to your email
Download our app via QR Code or the links below:.
+ 10 million
students
Free and Valid
Certificate
60 thousand free
exercises
4.8/5 rating in
app stores
Free courses in
video and ebooks