Sub topic 4
Finding the mean with AVERAGE
Assume you can enter formulas in Google Sheets and read cell addresses such as B2. A range is a group of cells, such as B2:B6. The AVERAGE function calculates the arithmetic mean of numeric values in a range.
The mean is found by adding the values and dividing the total by the number of numeric values:
\[ \text{mean}=\frac{\text{sum of values}}{\text{number of values}} \]
Calculate an average from a range
Suppose column B contains weekly sales:
| A | B |
|---|---|
| Week 1 | 120 |
| Week 2 | 150 |
| Week 3 | 90 |
| Week 4 | 140 |
| Week 5 | 100 |
Enter this formula in another cell:
=AVERAGE(B2:B6)Google Sheets adds the five values, divides by five, and returns 120. The range includes both endpoints, B2 and B6.
You can also average a row or a rectangular area. For example, =AVERAGE(B2:F2) averages five cells across one row. A range can contain formulas that return numbers; those results are included.
How AVERAGE treats cell contents
When the argument is a cell range, AVERAGE uses numeric values. It ignores blank cells and text in cells. A zero is a number, so it is included and can lower the result. A number stored as text, such as the text value "120", is not treated like the numeric value 120 when it is inside a referenced range.
| Cell content | Included in `AVERAGE(A1:A4)`? |
|---|---|
| `25` | Yes |
| `0` | Yes |
| Blank cell | No |
| Text such as `unknown` | No |
This behavior can make an average look higher than expected when missing values are represented by blanks. A blank does not count as zero. If a missing measurement should count as zero for your analysis, enter 0 deliberately.
Understand errors and precision
If the range contains no numeric values, AVERAGE returns #DIV/0! because it has no values to divide by. If a referenced cell contains an error, the error normally passes through to the result.
Use IFERROR when an empty or incomplete range is an expected situation:
=IFERROR(AVERAGE(B2:B6), "No data")This displays No data instead of an error when no numeric value is available. Do not use IFERROR to hide errors that indicate damaged or incorrectly entered data.
The underlying average may contain many decimal places. To control the result’s precision, nest AVERAGE inside ROUND:
=ROUND(AVERAGE(B2:B6), 2)The second argument, 2, requests two decimal places. Rounding changes the displayed result returned by the formula. It does not repair incorrect source data.
Follow the calculation
For the sales example, the calculation is (120 + 150 + 90 + 140 + 100) / 5, which equals 120.
Exercise
A range contains 10, 0, a blank cell, and the text missing. What does =AVERAGE(A1:A4) return?
Show answer
It returns 5. The function uses 10 and 0, ignores the blank and text, and divides 10 by 2.