Sub topic 13
Counting and filtering blanks
This chapter assumes you can write a basic COUNTIFS or SUMIFS formula and understand ranges and criteria pairs. Here you will learn how to match empty cells and filled cells, and where each form can go wrong.
Why blanks need their own criteria
Real data often has gaps. In the sample sales layout, column E holds notes, and most rows have none. You may want to know how many West sales have no note, or how much revenue sits in rows that do have one. Blank criteria answer these questions.
The two blank criteria
Two criteria strings do the work:
| Criterion | Matches |
|---|---|
| `""` | Cells that are empty, or that contain an empty string |
| `"<>"` | Cells that are not empty |
This formula counts West rows with no note:
=COUNTIFS(B2:B100, "West", E2:E100, "")Swap the criterion to count West rows that do have a note:
=COUNTIFS(B2:B100, "West", E2:E100, "<>")You can also add up amounts. This totals Amount for rows that have a note:
=SUMIFS(D2:D100, E2:E100, "<>")The two counts for a region should add up to the number of rows for that region. Use that as a quick check.
What counts as blank
Excel's idea of blank is narrower than it looks. Three cases catch people out:
- A cell that holds a formula returning
""is matched by the""criterion. It is also matched by"<>"in some cases, depending on the function. Do not rely on one result for formula cells. Test your own data. - A cell that contains a single space looks empty but is text. It is not blank, so
""will not match it, and"<>"will. - A cell that contains
0is not blank. Zero is a value.
If your counts look too low for blanks, look for stray spaces. Select the column and use Find and Replace to search for a single space, or add a helper column with =LEN(E2) to see which "empty" cells have a length above zero.
Blank criteria on the sum range
Blank criteria work on any criteria range. Blank cells in the sum range itself are different. SUMIFS ignores empty cells there, and AVERAGEIFS leaves them out of both the total and the count. So a blank Amount does not drag an average toward zero, while a typed 0 does.
Common errors
- Using
"="alone. The criterion"="matches only truly empty cells. It is stricter than"", so it skips cells that hold an empty string from a formula. - Forgetting the quotes. Writing
<>without quotes causes a formula error. Criteria must be text. - Mismatched ranges. The blank range must be the same size as the sum range. A shorter
E2:E99againstD2:D100returns#VALUE!.
Exercise
Which formula counts rows in B2:B100 where Region is "East" and the Notes cell in E2:E100 is filled in?
Show answer
=COUNTIFS(B2:B100, "East", E2:E100, "<>")
Exercise
A COUNTIFS with the criterion "" on column E returns fewer rows than you can see are empty. What is the likely cause, and how can you find it?
Show answer
Some cells that look empty hold a space or an empty-string result, so they are not truly blank. Add a helper column with =LEN(E2) and look for values above zero.