Sub topic 11
Counting and summing blank and non-blank cells
This chapter assumes you can write COUNTIFS, SUMIFS, and AVERAGEIFS with one or more criteria pairs, and that you know the argument order: the range to sum or average comes first, then criteria range and criteria pairs. Here you will use criteria that test whether a cell is empty, so you can find incomplete rows, count completed ones, and total values by whether another column was filled in.
Why blank criteria matter
Real data has gaps. A Product cell may be empty because someone forgot to enter it. A "Ship date" cell may be empty because the order has not shipped yet. In both cases the blank is information. Blank and non-blank criteria let you answer questions such as:
- How many West rows are missing a product?
- What is the total revenue of orders that have not shipped?
- What is the average revenue of rows that have a product name?
The examples use this layout, with data in rows 2 to 100:
| Column | Header | Contents |
|---|---|---|
| A | Region | Text such as West, East |
| B | Product | Text, sometimes empty |
| C | Date | Order date |
| D | Units | Number |
| E | Revenue | Number |
The two core criteria
Two criteria cover most blank tests.
"<>"means "not empty". The<>operator means "not equal to", and with nothing after it, the thing a cell must differ from is emptiness.""(an empty text string) means "empty".
Count West rows where the Product cell is filled in:
=COUNTIFS(A2:A100, "West", B2:B100, "<>")Count West rows where the Product cell is empty:
=COUNTIFS(A2:A100, "West", B2:B100, "")The two results add up to the number of West rows. That makes a handy check: if they do not add up to =COUNTIFS(A2:A100, "West"), some cells are not behaving as you expect (see the section on empty-looking cells below).
The same criteria work in SUMIFS and AVERAGEIFS. The criteria range is the column you test for emptiness, and the sum range is a different column:
=SUMIFS(E2:E100, B2:B100, "")This totals the Revenue of rows that have no product. It is a quick way to see how much money is affected by missing data.
=AVERAGEIFS(E2:E100, B2:B100, "<>")This averages Revenue only for rows that have a product name.
A diagram of the decision
Blank tests combined with other criteria
Blank criteria are ordinary criteria pairs, so they combine with AND like any other. Every pair must be true for a row to count.
Count rows in the West region, with a product, and at least 10 units:
=COUNTIFS(A2:A100, "West", B2:B100, "<>", D2:D100, ">=10")Sum revenue for rows in January 2026 that have no product:
=SUMIFS(E2:E100, B2:B100, "", C2:C100, ">="&DATE(2026,1,1), C2:C100, "<"&DATE(2026,2,1))Here the date column is used twice, once for the start and once for the exclusive end, exactly as in the date chapter. The blank test sits beside it as one more pair.
What counts as empty
A cell that looks empty is not always empty. There are three common cases.
- A truly empty cell. Nothing was ever typed in it. It matches
"". - A cell containing only a space. It looks blank, but it holds a character. It does not match
"", and it does match"<>". This often happens with pasted data. - A cell whose formula returns an empty string, such as
=IF(D2>0, D2, ""). It looks blank, but it contains a formula. How such cells match"<>"is the easiest place to get a surprising result, so test your own sheet with the check described below.
To check, put =COUNTIFS(B2:B100, "") and =COUNTIFS(B2:B100, "<>") next to each other. The two results should add up to 99, the number of rows in B2:B100. If they do, your blank handling is consistent. If they do not, inspect the cells that break the pattern. Click one and look at the formula bar, or use =LEN(B5) to find cells that hold a space.
Text only: the "?*" criterion
Sometimes you want cells that contain at least one character of text, and you want to skip blanks and numbers. The wildcard pattern "?*" does this. The ? requires one character and the * allows any number more.
=COUNTIFS(B2:B100, "?*")Because the pattern matches text, it ignores numeric cells. It also does not match a truly empty cell, because there is no character for ? to match. It is a useful stricter alternative to "<>" when the column should only hold names.
| Criterion | Matches truly empty cell | Matches a cell holding text | Matches a cell holding a number |
|---|---|---|---|
| `""` | Yes | No | No |
| `"<>"` | No | Yes | Yes |
| `"?*"` | No | Yes | No |
A cell with an empty-string formula result is the exception to this table, as described above, so check those cells in your own sheet.
Related functions and how they differ
Google Sheets has simpler functions for blank counting. They take no conditions on other columns, so you use them for whole-range totals only.
COUNTBLANK(B2:B100)counts empty cells in a range, and includes cells with an empty-string formula result.COUNTA(B2:B100)counts cells that are not empty, and also counts cells that contain a formula returning"".
If you need "blank AND in the West region", use COUNTIFS. COUNTBLANK cannot take a second condition.
Empty criteria cells
Chapter techniques often put criteria in cells, as in ">"&H1. Be careful when the criteria cell itself is empty. An empty criteria cell does not reliably mean "match blank cells" or "match everything". Write the blank test explicitly in the formula, as "" or "<>", or let a dropdown cell hold a clear text choice and wrap the logic in IF.
=IF(H1="Missing", COUNTIFS(A2:A100, "West", B2:B100, ""), COUNTIFS(A2:A100, "West", B2:B100, "<>"))This formula reads a choice from H1 and picks the matching blank test.
Whole-column ranges
Be careful with B:B in blank tests. A criterion of "" also matches every empty cell below your data, which could be a million rows. A formula such as =COUNTIFS(B:B, "") would return a huge number rather than the number of incomplete rows. Use a bounded range such as B2:B100, and keep it the same size as the other ranges in the formula.
Handling a result of zero rows
AVERAGEIFS with a blank test can return #DIV/0! when no row matches. For example, if every row has a product, =AVERAGEIFS(E2:E100, B2:B100, "") has nothing to average. Wrap it as before:
=IFERROR(AVERAGEIFS($E$2:$E$100, $B$2:$B$100, ""), "No matches")COUNTIFS and SUMIFS return 0 in that case, so they need no wrapper.
Exercises
Exercise
Write one formula that totals Revenue (E2:E100) for rows in the East region (A2:A100) where the Product (B2:B100) is filled in. Then write the companion formula for East rows where Product is empty. What check tells you the two results are consistent?
Show answer
Filled in: =SUMIFS(E2:E100, A2:A100, "East", B2:B100, "<>"). Empty: =SUMIFS(E2:E100, A2:A100, "East", B2:B100, ""). Add the two results. The sum should equal =SUMIFS(E2:E100, A2:A100, "East"). If it does not, some cells hold spaces or formula-generated empty text.
Exercise
=COUNTIFS(B:B, "") returns a number over 900,000 on a sheet with 99 data rows. Why, and how do you fix it?
Show answer
The criterion "" matches every empty cell, and a whole-column range includes all the empty rows below the data. Use a bounded range such as B2:B100.