Sub topic 8
What the functions ignore: text, blanks, and zeros
This chapter explains which cells SUM, AVERAGE, COUNT, MIN, and MAX skip and which they use. It assumes you can enter data and formulas in Google Sheets, read cell addresses such as B2, and write a range such as B2:B6. The earlier chapters on each function cover the syntax.
The rule in one sentence
When you pass a range to these five functions, they use only the cells that hold numbers. Text and empty cells are skipped without an error. A zero is a number, so every function uses it.
This causes the most silent mistakes in basic Sheets work. A skipped cell never shows an error, so the formula looks fine while it computes the wrong answer.
Dates and times are numbers in Sheets, so these functions use them too. They are stored as day counts, so a date can inflate a SUM you didn't mean to include it in.
A test dataset
The examples below use this small table in A1:B6.
| Cell | Content | Kind of value |
|---|---|---|
| B2 | 10 | number |
| B3 | 20 | number |
| B4 | (nothing typed) | empty cell |
| B5 | 0 | number (zero) |
| B6 | n/a | text |
Enter these formulas in column D and compare your results with the table that follows.
=SUM(B2:B6)
=AVERAGE(B2:B6)
=COUNT(B2:B6)
=MIN(B2:B6)
=MAX(B2:B6)| Formula | Result | Why |
|---|---|---|
| SUM | 30 | 10 + 20 + 0. The text and the empty cell add nothing. |
| AVERAGE | 10 | 30 divided by 3. Only three cells are numbers. |
| COUNT | 3 | The cells holding 10, 20, and 0. |
| MIN | 0 | The zero is a real number and is the smallest. |
| MAX | 20 | The largest number. |
The AVERAGE result is the important one. It is 30 / 3, not 30 / 5 and not 30 / 4. The divisor is the count of numeric cells, which is what COUNT returns.
How each cell is classified
Each function checks every cell in the range and sorts it into one of the groups in this diagram.
Blanks versus zeros
An empty cell and a cell containing 0 look similar, but they behave differently.
- A zero is counted by COUNT, pulls AVERAGE down, and can be the result of MIN.
- An empty cell is not counted, does not affect AVERAGE, and cannot be the result of MIN or MAX.
Change B4 in the test dataset from empty to 0 and the results change.
| Formula | B4 empty | B4 is 0 |
|---|---|---|
| SUM(B2:B6) | 30 | 30 |
| COUNT(B2:B6) | 3 | 4 |
| AVERAGE(B2:B6) | 10 | 7.5 |
SUM does not change, because adding zero changes nothing. COUNT and AVERAGE do change, because they depend on how many cells are numbers.
Choose between blank and zero by what the data means. If a store was closed and made no sales, leave the cell blank so the average covers only days it was open. If a store was open and sold nothing, enter 0 so that day lowers the average.
Text, including empty strings
Any text in a range is skipped, such as "n/a", "pending", or "-". This is convenient when a column mixes notes and numbers, and risky when a number was typed as text by mistake.
A formula that returns "" produces an empty string. It looks blank, but it is text. COUNT and AVERAGE skip it, like any text. That makes "" the usual way to leave a gap that aggregates ignore.
=IF(C2="", "", C2*1.2)This formula returns a blank-looking cell when C2 is empty. It is text, so a later AVERAGE over that column skips it.
COUNTA and COUNTBLANK treat these cells differently. COUNTA counts the "" cell as non-empty, but COUNTBLANK counts it as blank. The next chapter covers that mismatch.
Numbers stored as text
A number stored as text is a value such as 20 that Sheets treats as a string. This happens often after pasting from a website, importing a CSV file, or typing an apostrophe before a number. In a range, SUM, AVERAGE, COUNT, MIN, and MAX skip it, because it is text.
Change B3 in the test dataset to the text 20:
| Formula | Result | Why |
|---|---|---|
| SUM(B2:B6) | 10 | Only 10 and 0 are numbers. |
| COUNT(B2:B6) | 2 | The text "20" is not counted. |
| AVERAGE(B2:B6) | 5 | 10 divided by 2. |
| MAX(B2:B6) | 10 | The text "20" is never a candidate. |
The total is 20 less than it should be, and no error appears.
How to spot them
- By default, numbers are right-aligned and text is left-aligned. A left-aligned number in a numeric column is suspicious. Manual alignment can hide this clue.
- A leading apostrophe may show in the formula bar, though not in the cell.
=ISNUMBER(B3)returns TRUE for a real number and FALSE for text.=ISTEXT(B3)does the reverse.- Compare
=COUNT(B2:B6)with=COUNTA(B2:B6). If a column should hold only numbers and COUNTA is larger than COUNT, some cells hold text.
How to fix them
For a one-time fix, select the cells and use Format > Number > Automatic. Then re-enter the values. Re-entering matters because changing the format alone does not always convert existing text. A cell with a leading apostrophe has to be retyped without it.
To convert without touching the source cells, use VALUE inside an array formula:
=SUM(ARRAYFORMULA(IFERROR(VALUE(B2:B6), 0)))VALUE turns text such as "20" into the number 20. IFERROR replaces values that cannot be converted, such as "n/a", with 0. Every cell in the range then counts toward the sum, including the 0s from failed conversions. For AVERAGE this changes the divisor, so use this pattern for SUM and be careful with the other functions.
Cells with spaces and hidden characters
A cell that looks empty may contain a space or a non-breaking space copied from a web page. It is text, so aggregates skip it, but COUNTA counts it as non-empty. If COUNTA reports more cells than you can see, look for these. =LEN(B4) returns 0 for a truly empty cell and 1 or more for a cell holding invisible characters.
What happens when nothing qualifies
If a range holds no numbers at all, the functions behave differently.
| Formula | Result with no numbers in range |
|---|---|
| SUM | 0 |
| COUNT | 0 |
| MIN | 0 |
| MAX | 0 |
| AVERAGE | #DIV/0! error |
MIN and MAX return 0 when the range has no numbers, so a 0 does not prove that a real zero exists. Cross-check with COUNT. AVERAGE fails because it would divide by a count of zero. The errors chapter shows how to handle that case.
A checklist before trusting a result
- Run
=COUNT(range)and compare it with the number of rows you expect to be numeric. - Run
=COUNTA(range). If it is larger than COUNT, find the text cells. - Decide whether each empty cell is missing data (leave blank) or a true zero (enter 0).
- For left-aligned numbers, retype them or convert them with VALUE.
Exercise
B2:B6 contains 8, 12, the text "12" (stored as text), an empty cell, and 0, in that order. What do SUM, COUNT, and AVERAGE return, and which cell would you fix to make the total correct?
Show answer
SUM is 20 (8 + 12 + 0), COUNT is 3 (8, 12, and 0), and AVERAGE is 20 / 3 = 6.67 (about 6.6667). The text "12" and the empty cell are skipped. Fix the cell holding the text "12" by re-entering it as a number. SUM then becomes 32, COUNT becomes 4, and AVERAGE becomes 8.
Exercise
A column of daily sales has some days left empty because the store was closed. A colleague wants the average to include those days as zero sales. What do you change, and how does AVERAGE change?
Show answer
Enter 0 in the closed days instead of leaving them empty. Empty cells are skipped, so they do not affect the divisor. Zeros are numbers, so they raise the count and lower the average. For example, with sales of 10 and 20 and one closed day, the average changes from 15 to 10 (30 / 3).