Aral Code

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

ABCD
1DateItemCategoryAmount
22026-11-02KapeDrinks32
32026-11-02PandesalBread25
42026-11-03SoftdrinkDrinks75
52026-11-03SardinasCanned72
62026-11-04KapeDrinks40
72026-11-04PandesalBread50

COUNTIF

=COUNTIF(range, criteria)
ABC
1FormulaResultMeaning
2=COUNTIF(C2:C7, "Drinks")3Number of drink sales
3=COUNTIF(D2:D7, ">=50")3Sales of ₱50 or more
4=COUNTIF(B2:B7, "K*")2Items starting with K
5=COUNTIF(B2:B7, "<>Kape")4Items 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)
AB
1FormulaResult
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:

AB
1FormulaResult
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

ABC
1StudentSectionGrade
2AnaRizal88
3BenMabini72
4CarlaRizal95
5DanMabini81
6ElaRizal70
ABC
8Passed=COUNTIF(C2:C6, ">=75")3
9Failed=COUNTIF(C2:C6, "<75")2
10Passing rate=COUNTIF(C2:C6, ">=75")/COUNT(C2:C6)60%
11Rizal average=AVERAGEIF(B2:B6, "Rizal", C2:C6)84.33
12Rizal 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. 🙂

1. Which counts grades of 75 and above in C2:C41?
2. In SUMIFS, which argument comes first?
3. What does the criteria "K*" match?
4. How do you use a number in cell G2 as a "greater than or equal" criteria?

By Sir Reyel · Last updated 2026-12-04