Sub topic 11
How blanks, text, logical values, and zeros affect results
This chapter assumes you can write =SUM(B2:B6) and know what a range is. It covers what these functions do with cells that are not plain numbers. This is the usual source of totals that look wrong.
The rule for ranges
When you pass a range, SUM, AVERAGE, MIN, MAX, and COUNT use only the numeric cells. They skip blank cells, text, and logical values (TRUE and FALSE). Dates are numbers, so they are included.
A worked example
Suppose B2:B6 holds these five cells:
| Cell | Content |
|---|---|
| B2 | 10 |
| B3 | (empty) |
| B4 | n/a (text) |
| B5 | 0 |
| B6 | TRUE |
Only B2 and B5 are numeric, so the results follow from those two cells.
=SUM(B2:B6)
=COUNT(B2:B6)
=AVERAGE(B2:B6)
=MIN(B2:B6)
=MAX(B2:B6)These return 10, 2, 5, 0, and 10. The average is 5 because the zero counts as a value: (10 + 0) / 2. The empty cell, the text, and TRUE do not change it.
The counting functions give different answers on the same range:
=COUNTA(B2:B6)
=COUNTBLANK(B2:B6)COUNTA returns 4 because it counts every non-empty cell, including text and TRUE. COUNTBLANK returns 1.
Zeros are data, blanks are not
A zero is a real number. It lowers an average, can become the MIN, and is counted by COUNT. A blank cell does none of these things. If an unreported value is stored as 0, your average is too low. Leave the cell empty when the value is unknown.
MIN and MAX return 0 when the range has no numbers at all. A result of 0 therefore does not prove a zero was entered.
Numbers stored as text
A value like 25 that is left-aligned or shows a green corner triangle is often text. Ranges skip it, so the total comes out low with no error. Convert it with Data > Text to Columns or by multiplying a copy by 1.
Empty strings from formulas
A formula that returns "" looks blank, but it is not empty.
| Function | Treats `""` as |
|---|---|
| `COUNT` | Not a number, so it is skipped |
| `COUNTA` | Filled, so it is counted |
| `COUNTBLANK` | Blank, so it is counted |
Because of this, COUNTA and COUNTBLANK can both include the same cell.
Typed arguments behave differently
Values you type directly into the function are not skipped. Logical values and numbers written as text are converted:
=SUM(10, TRUE)
=SUM(10, "5")
=COUNT(10, TRUE, "5")These return 11, 15, and 3. Text that cannot be read as a number, such as =SUM(10, "abc"), returns #VALUE!. The same value inside a referenced cell would be skipped.
Errors are not skipped
If any cell in the range holds an error, the function returns that error. One #N/A in B2:B6 makes SUM, AVERAGE, MIN, and MAX all return #N/A. COUNT is the exception, because it counts only numbers. COUNTA counts the error cell as filled.
Exercise
A range A1:A5 contains 4, 6, an empty cell, the text "none", and 0. What do SUM, AVERAGE, COUNT, and COUNTA return?
Show answer
SUM returns 10. COUNT returns 3, because the cells holding 4, 6, and 0 are numeric. AVERAGE returns 10/3, about 3.33, because the zero counts and the empty cell and text do not. COUNTA returns 4, because it counts every non-empty cell, including the text.