Functions Lesson 7 of 13
Excel COUNTIF, SUMIF, AVERAGEIF and the IFS Versions
Count, add and average only the rows that match a condition with COUNTIF, SUMIF and AVERAGEIF, and use COUNTIFS and SUMIFS for several conditions, with sales and grade examples.
COUNT and SUM work on everything. But often you want only some rows: how many students passed, total sales of drinks, average grade of section Rizal. That's what the "IF" functions do.
The data
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Date | Item | Category | Amount |
| 2 | 2026-11-02 | Kape | Drinks | 32 |
| 3 | 2026-11-02 | Pandesal | Bread | 25 |
| 4 | 2026-11-03 | Softdrink | Drinks | 75 |
| 5 | 2026-11-03 | Sardinas | Canned | 72 |
| 6 | 2026-11-04 | Kape | Drinks | 40 |
| 7 | 2026-11-04 | Pandesal | Bread | 50 |
COUNTIF
=COUNTIF(range, criteria)
| A | B | C | |
|---|---|---|---|
| 1 | Formula | Result | Meaning |
| 2 | =COUNTIF(C2:C7, "Drinks") | 3 | Number of drink sales |
| 3 | =COUNTIF(D2:D7, ">=50") | 3 | Sales of ₱50 or more |
| 4 | =COUNTIF(B2:B7, "K*") | 2 | Items starting with K |
| 5 | =COUNTIF(B2:B7, "<>Kape") | 4 | Items that aren't Kape |
Criteria are written as text in quotes. * matches any characters and ? matches one character, like LIKE in SQL.
Criteria from a cell
=COUNTIF(C2:C7, G1)
=COUNTIF(D2:D7, ">="&G2)
Here G1 contains the text Drinks and G2 contains 50. When combining an operator with a cell, join them with &. Changing G1 or G2 updates the count, which is great for dashboards.
SUMIF
=SUMIF(range_to_check, criteria, range_to_add)
| A | B | |
|---|---|---|
| 1 | Formula | Result |
| 2 | =SUMIF(C2:C7, "Drinks", D2:D7) | 147 |
| 3 | =SUMIF(C2:C7, "Bread", D2:D7) | 75 |
| 4 | =SUMIF(D2:D7, ">50") | 147 |
When the range to check and the range to add are the same, you can leave out the third argument, as in the last row.
AVERAGEIF
=AVERAGEIF(C2:C7, "Drinks", D2:D7)
Result: 49 (147 ÷ 3).
Several conditions: COUNTIFS, SUMIFS, AVERAGEIFS
The "S" versions accept any number of range–criteria pairs. All conditions must be true:
| A | B | |
|---|---|---|
| 1 | Formula | Result |
| 2 | =COUNTIFS(C2:C7, "Drinks", D2:D7, ">=40") | 2 |
| 3 | =SUMIFS(D2:D7, C2:C7, "Drinks", A2:A7, "2026-11-04") | 40 |
| 4 | =SUMIFS(D2:D7, B2:B7, "Pandesal", A2:A7, ">=2026-11-03") | 50 |
Class record example
| A | B | C | |
|---|---|---|---|
| 1 | Student | Section | Grade |
| 2 | Ana | Rizal | 88 |
| 3 | Ben | Mabini | 72 |
| 4 | Carla | Rizal | 95 |
| 5 | Dan | Mabini | 81 |
| 6 | Ela | Rizal | 70 |
| A | B | C | |
|---|---|---|---|
| 8 | Passed | =COUNTIF(C2:C6, ">=75") | 3 |
| 9 | Failed | =COUNTIF(C2:C6, "<75") | 2 |
| 10 | Passing rate | =COUNTIF(C2:C6, ">=75")/COUNT(C2:C6) | 60% |
| 11 | Rizal average | =AVERAGEIF(B2:B6, "Rizal", C2:C6) | 84.33 |
| 12 | Rizal passed | =COUNTIFS(B2:B6, "Rizal", C2:C6, ">=75") | 2 |
Column B shows the formulas and column C their results.
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04