Imagine you are a teacher in a secondary school in Ibadan. You have a spreadsheet containing the names and examination scores of 100 students. You want to know how many students passed, how many students have submitted their assignments, and how many students scored at least 70 marks.
Counting and conditional functions in Microsoft Excel can help you answer these questions quickly without counting everything manually.
By the end of this module, you should be able to:
Counting functions help you find out how many cells contain numbers, information, or empty spaces in a spreadsheet.
For example, a school administrator can use counting functions to find out how many students registered for an examination.
The COUNT function counts cells that contain numbers. It does not count text or empty cells.
Example: Imagine these examination scores are stored in cells B2 to B6:
| Student | Score |
|---|---|
| Ade | 75 |
| Chika | 90 |
| Tunde | 65 |
| Fatima | Absent |
| Emeka | 85 |
To count the number of students with numerical scores, enter:
=COUNT(B2:B6)
Result: 4
This is because four cells contain numbers.
COUNTA counts all cells that are not empty. These cells may contain numbers, names, dates, or other text.
Example: To count how many student names are entered in cells A2 to A6, use:
=COUNTA(A2:A6)
Result: 5
It counts all five names because none of the cells is empty.
COUNTBLANK counts the number of empty cells in a selected range.
Example: If some students have not entered their examination scores, you can find the empty score cells with:
=COUNTBLANK(B2:B6)
The function returns the number of empty cells in the selected range.
COUNTIF counts cells that meet one condition. A condition is a rule you want Excel to check.
For example, you may want to count students who scored 70 marks or more.
=COUNTIF(range, criteria)
Assume the scores are stored in cells B2 to B6:
| Student | Score |
|---|---|
| Ade | 75 |
| Chika | 90 |
| Tunde | 65 |
| Fatima | 55 |
| Emeka | 85 |
Enter this formula:
=COUNTIF(B2:B6,">=70")
Result: 3
Excel counts Ade, Chika, and Emeka because their scores are 70 or higher.
=COUNTIF(B2:B20,">=50") counts scores of 50 or more.=COUNTIF(B2:B20,"<50") counts scores below 50.=COUNTIF(C2:C20,"Food") counts cells containing the word Food.=COUNTIF(D2:D20,"Pass") counts cells containing Pass.COUNTIFS is similar to COUNTIF, but it allows you to check more than one condition at the same time.
For example, a teacher may want to count students who belong to JSS 2 and scored at least 70 marks.
=COUNTIFS(criteria_range1, criteria1, criteria_range2, criteria2)
Each criteria range is the group of cells Excel checks, while each criteria is the rule those cells must meet.
| Student | Class | Score |
|---|---|---|
| Ade | JSS 2 | 80 |
| Chika | JSS 1 | 90 |
| Tunde | JSS 2 | 65 |
| Fatima | JSS 2 | 75 |
| Emeka | JSS 3 | 85 |
To count students in JSS 2 who scored at least 70, enter:
=COUNTIFS(B2:B6,"JSS 2",C2:C6,">=70")
Result: 2
Ade and Fatima meet both conditions.
The IF function helps Excel make decisions. It checks whether a condition is true or false and displays a result based on the answer.
Think of it like a teacher checking whether a student has passed an examination.
=IF(logical_test, value_if_true, value_if_false)
Assume a student must score at least 50 marks to pass. The student's score is in cell B2.
Enter this formula in cell C2:
=IF(B2>=50,"Pass","Fail")
If the score is 75, Excel displays Pass. If the score is 40, Excel displays Fail.
| Student | Score | Result |
|---|---|---|
| Ade | 75 | Pass |
| Chika | 90 | Pass |
| Tunde | 35 | Fail |
| Fatima | 45 | Fail |
| Emeka | 85 | Pass |
After entering the formula in C2, drag the small square at the bottom-right corner of the cell downwards to apply it to the other students.
Imagine a supermarket in Ibadan wants to analyse its product records.
| Product | Category | Quantity Sold | Price (โฆ) |
|---|---|---|---|
| Rice | Food | 20 | 50000 |
| Beans | Food | 15 | 30000 |
| Soap | Household | 10 | 5000 |
| Milk | Food | 12 | 20000 |
| Detergent | Household | 8 | 7000 |
Count all products with numerical prices:
=COUNT(D2:D6)
Count all products with names entered:
=COUNTA(A2:A6)
Count products in the Food category:
=COUNTIF(B2:B6,"Food")
Count products in the Food category with a price of at least โฆ20,000:
=COUNTIFS(B2:B6,"Food",D2:D6,">=20000")
Classify a product as Expensive or Affordable:
=IF(D2>=20000,"Expensive","Affordable")
Note: Some Excel regional settings use semicolons instead of commas to separate formula arguments. If a formula gives an error, check your Excel settings.
A school in Lagos has recorded the examination scores of five students. Enter the information into Excel and answer the questions below.
| Student | Class | Score |
|---|---|---|
| David | JSS 1 | 65 |
| Mary | JSS 2 | 85 |
| John | JSS 1 | 45 |
| Grace | JSS 2 | 70 |
| Peter | JSS 3 | 90 |
In this module, you learned how to use Excel counting and conditional functions.
These functions make it easier to analyse school records, supermarket sales, business information, and other types of data.
In Module 4, you will learn about Logical Functions in Excel, including AND, OR, and NOT. These functions will help you check multiple conditions and make more advanced decisions using spreadsheet data.