Sub topic 4
Finding the mean with AVERAGE
This chapter assumes you can enter values and formulas in Google Sheets and read cell addresses such as B2. It also assumes you know what a range such as B2:B6 is and have seen SUM. By the end you should be able to predict what AVERAGE returns for messy data, explain why, and handle the cases where it fails.
What AVERAGE computes
AVERAGE returns the arithmetic mean: the sum of the numeric values divided by how many numeric values there are.
=AVERAGE(B2:B6)The result is the same as the following formula, which shows the mechanism:
=SUM(B2:B6) / COUNT(B2:B6)The divisor is COUNT, not the number of cells in the range. This is the most important fact about AVERAGE. Cells that are not numbers are left out of both the sum and the divisor. They do not count as zero.
A worked example
Suppose a teacher records quiz scores in column B:
| Cell | Content | Notes |
|---|---|---|
| B2 | 70 | number |
| B3 | 90 | number |
| B4 | (empty) | student has not taken the quiz yet |
| B5 | absent | text |
| B6 | 0 | number, a real score of zero |
Now compare three formulas:
=AVERAGE(B2:B6)
=SUM(B2:B6)
=COUNT(B2:B6)SUM(B2:B6)is 160, because 70 + 90 + 0 = 160.COUNT(B2:B6)is 3, because only B2, B3 and B6 hold numbers.AVERAGE(B2:B6)is 160 / 3, about 53.33.
If the sheet had treated the empty cell and the text as zeros, the divisor would be 5 and the answer would be 32. That is a very different result. Sheets does not do this, so the blank and the text do not drag the average down. The zero in B6 does lower the average, because a zero is a number.
How AVERAGE treats each kind of cell
The following diagram shows the decision AVERAGE makes for each cell in a range.
The table below lists the common cases.
| Cell content | In the range? | Effect on AVERAGE |
|---|---|---|
| `85` | Yes | Included in sum and count |
| `0` | Yes | Included. It lowers the mean |
| Empty cell | Yes | Ignored |
| Text such as `absent` | Yes | Ignored |
| Number stored as text, such as `"85"` left-aligned | Yes | Ignored |
| Empty string `""` returned by a formula | Yes | Ignored, because it is text |
| `TRUE` or `FALSE` | Yes | Ignored when it sits in a range |
| Date or time | Yes | Included. Dates are numbers underneath |
| `#N/A`, `#REF!`, `#DIV/0!` | Yes | The whole formula returns the error |
Checking your divisor
A reliable habit is to place the count next to the average. This shows how many values the mean is really based on.
=AVERAGE(B2:B6)
=COUNT(B2:B6)
=COUNTA(B2:B6)If COUNT and COUNTA differ, some cells in the range are non-empty but not numeric. In the worked example, COUNT is 3 and COUNTA is 4, since B5 holds text. That gap tells you one cell was skipped on purpose or by accident.
Averaging several ranges and values
Like SUM, AVERAGE accepts more than one argument. All arguments are pooled before the division.
=AVERAGE(B2:B6, D2:D6, 100)This computes one mean over every numeric value in both ranges plus the literal 100. It is not the average of three separate averages. The difference matters when the ranges have different numbers of values. If B2:B6 holds two numbers averaging 80, and D2:D6 holds eight numbers averaging 60, the pooled mean is 64, not 70.
Use a comma between arguments. Using a colon between two separate cells such as B2:D2 selects the whole rectangle between them, which may include cells you did not intend.
Errors and the empty-data case
If the range contains no numbers at all, the divisor is zero and AVERAGE returns #DIV/0!. This often happens at the start of a sheet, before any data is entered, or when a filter or a formula upstream produces only text.
=IFERROR(AVERAGE(B2:B6), "No data")IFERROR returns its second argument when the first one produces any error. That is convenient, but it hides every error, not just #DIV/0!. If B3 held #REF! because someone deleted a column, this formula would also show "No data", and the real problem would be invisible. Use IFERROR on the final display cell, and keep the raw AVERAGE visible somewhere while you are building and checking the sheet.
An error in a single cell of the range makes the whole average fail. To find the cause, look for the first error cell in the range, fix it, and the average will recover.
Rounding the result
Averages often have long decimals. Wrap the result in ROUND to control it:
=ROUND(AVERAGE(B2:B6), 2)For the worked example, this returns 53.33. Rounding with ROUND changes the stored value. Formatting a cell to show two decimals changes only the display, and later formulas still use the full-precision value. Choose ROUND when the rounded figure is the one you want to report or reuse, and use formatting when you want to keep full precision underneath.
Functions can be nested to any reasonable depth. Sheets evaluates from the inside out: AVERAGE runs first, then ROUND, then IFERROR if it is the outer function.
=IFERROR(ROUND(AVERAGE(B2:B6), 2), "No data")When a plain average is the wrong tool
Three situations call for something else.
- Zeros that mean "missing." If a zero in your data really means "not recorded,"
AVERAGEwill include it and pull the mean down.AVERAGEIFcan exclude them:=AVERAGEIF(B2:B6, "<>0"). The next chapters on conditional functions cover this family in detail. - Averaging only some rows. If you need the mean of rows that match a condition, such as one product or one month, use
AVERAGEIF. For several conditions, useAVERAGEIFS. - Filtered data.
AVERAGEincludes rows hidden by a filter.SUBTOTALwith function code 1 averages only visible rows.
Two further points about interpretation. The mean is sensitive to outliers, so one value of 10,000 among values near 50 will dominate it. If that is a concern, compare it with MEDIAN. And if some values count more than others, such as grades with different weights, a plain mean gives the wrong answer. A weighted average needs SUMPRODUCT divided by SUM of the weights.
Summary of behavior
AVERAGE(range)equalsSUM(range) / COUNT(range).- Text, blanks, empty strings and logical values in a range are skipped. They do not count as zero.
- Real zeros are included.
- Numbers stored as text are skipped, which often explains a surprising result.
- No numeric values gives
#DIV/0!. Any error cell in the range makes the formula return that error. - Wrap in
ROUNDto change the value, and inIFERRORto replace an error with a message, taking care not to mask real problems.
Exercise
Cells C2:C7 contain 10, 20, the text "n/a", an empty cell, 0, and the number 30 stored as text (left-aligned). What does =AVERAGE(C2:C7) return, and what does =COUNT(C2:C7) return? Explain why.
Show answer
COUNT returns 3 and AVERAGE returns 10. The numeric cells are 10, 20 and 0, so the sum is 30 and the count is 3, giving 30 / 3 = 10. The text "n/a", the empty cell, and the number stored as text are all skipped, and the zero is included.
Exercise
Range B2:B4 holds only the words "pending", "pending", "pending". Write a formula that averages B2:B4 but shows the message "Waiting for data" instead of an error. Why does the original AVERAGE fail?
Show answer
=IFERROR(AVERAGE(B2:B4), "Waiting for data"). AVERAGE fails because the range contains no numbers, so the count is zero and the division gives #DIV/0!.