In previous modules, we learned how to use Excel functions to calculate totals, averages, count records, and find information. In this module, we will learn how to calculate totals and averages based on certain conditions.
Imagine you own a supermarket in Ibadan. You sell rice, beans, milk, bread, and other products. You may want to calculate only the total sales of rice or find the average sales of food products. Excel has special functions that can help you do this quickly.
We will learn four important functions:
By the end of this module, you should be able to:
A condition is a rule that tells Excel which information to use when performing a calculation.
For example, imagine a school has students from different classes. You may want to calculate the average score of only JSS 2 students instead of calculating the average score of everyone.
Instead of selecting the students manually, you can use a conditional function to let Excel do the work.
The SUMIF function adds numbers that meet one condition.
Syntax:
=SUMIF(range, criteria, [sum_range])
Meaning:
Example: A supermarket in Ibadan records the following sales:
| Product | Category | Sales (โฆ) |
|---|---|---|
| Rice | Food | 50,000 |
| Soap | Household | 15,000 |
| Beans | Food | 30,000 |
| Milk | Food | 20,000 |
| Detergent | Household | 10,000 |
Suppose the categories are in column B and sales are in column C. To calculate the total sales of Food products, enter:
=SUMIF(B2:B6,"Food",C2:C6)
Answer: โฆ100,000
Excel adds the sales of rice, beans, and milk because they belong to the Food category.
SUMIFS is similar to SUMIF, but it allows you to use more than one condition.
For example, you may want to calculate the total sales of Food products made at the Ibadan branch only.
Syntax:
=SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)
Example:
| Product | Category | Branch | Sales (โฆ) |
|---|---|---|---|
| Rice | Food | Ibadan | 50,000 |
| Soap | Household | Lagos | 15,000 |
| Beans | Food | Ibadan | 30,000 |
| Milk | Food | Lagos | 20,000 |
| Bread | Food | Ibadan | 10,000 |
Assume the categories are in column B, branches are in column C, and sales are in column D.
To calculate sales for Food products at the Ibadan branch, enter:
=SUMIFS(D2:D6,B2:B6,"Food",C2:C6,"Ibadan")
Answer: โฆ90,000
Excel adds only the sales records that meet both conditions:
Important: In SUMIFS, all the conditions must be satisfied before Excel includes a value in the calculation.
AVERAGEIF calculates the average of numbers that meet one condition.
For example, a teacher may want to calculate the average examination score of students in JSS 2 only.
Syntax:
=AVERAGEIF(range, criteria, [average_range])
Example:
| Student | Class | Score |
|---|---|---|
| Ade | JSS 1 | 70 |
| Chika | JSS 2 | 80 |
| Tunde | JSS 2 | 60 |
| Fatima | JSS 1 | 90 |
| Emeka | JSS 2 | 100 |
Assume the class names are in column B and the scores are in column C.
To calculate the average score of JSS 2 students, enter:
=AVERAGEIF(B2:B6,"JSS 2",C2:C6)
Answer: 80
Excel calculates the average of 80, 60, and 100. It ignores students in JSS 1.
AVERAGEIFS calculates the average of numbers that meet two or more conditions.
For example, a school may want to calculate the average score of JSS 2 students who scored at least 50 marks.
Syntax:
=AVERAGEIFS(average_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)
Example:
| Student | Class | Score |
|---|---|---|
| Ade | JSS 1 | 70 |
| Chika | JSS 2 | 80 |
| Tunde | JSS 2 | 40 |
| Fatima | JSS 1 | 90 |
| Emeka | JSS 2 | 100 |
Assume the class names are in column B and scores are in column C.
To calculate the average score of JSS 2 students who scored at least 50, enter:
=AVERAGEIFS(C2:C6,B2:B6,"JSS 2",C2:C6,">=50")
Answer: 90
Excel uses only Chika's score of 80 and Emeka's score of 100. Tunde's score is ignored because it is below 50.
Excel allows you to use comparison operators as conditions in your calculations.
| Operator | Meaning | Example |
|---|---|---|
| > | Greater than | >50 |
| < | Less than | <40 |
| >= | Greater than or equal to | >=50 |
| <= | Less than or equal to | <=60 |
| = | Equal to | =100 |
| <> | Not equal to | <>0 |
When using comparison operators as criteria in these functions, put the condition inside quotation marks.
For example:
=SUMIF(C2:C10,">=5000")
This adds all the numbers in the range C2:C10 that are greater than or equal to 5,000.
| Function | What It Does |
|---|---|
| SUMIF | Adds numbers that meet one condition. |
| SUMIFS | Adds numbers that meet multiple conditions. |
| AVERAGEIF | Calculates an average based on one condition. |
| AVERAGEIFS | Calculates an average based on multiple conditions. |
Remember: SUMIF and AVERAGEIF use one condition, while SUMIFS and AVERAGEIFS can use multiple conditions.
Also remember that SUMIFS starts with the sum range, while SUMIF starts with the condition range. AVERAGEIFS starts with the average range, while AVERAGEIF starts with the condition range.
Imagine you are helping a supermarket owner analyse sales records.
| Product | Category | Branch | Sales (โฆ) |
|---|---|---|---|
| Rice | Food | Ibadan | 40,000 |
| Soap | Household | Lagos | 15,000 |
| Beans | Food | Ibadan | 25,000 |
| Milk | Food | Lagos | 20,000 |
| Detergent | Household | Ibadan | 10,000 |
| Bread | Food | Ibadan | 5,000 |
Complete the following tasks using Excel:
In this module, we learned how to use four important Excel functions for data analysis:
These functions are useful when analysing school results, supermarket sales, business records, employee information, and many other datasets.
In the next module, we will learn how to combine Excel functions to solve more complex data analysis problems. You will discover how to use multiple functions together to clean, calculate, organise, and analyse information more efficiently.
Keep practising! The more you use Excel functions, the easier data analysis becomes.