3.3 COUNT, COUNTA, COUNTBLANK, COUNTIF and COUNTIFS
Count the thing you intend to report
Imagine you help a fictional restaurant team organize reports inspired by Swiggy. Eight support tickets have IDs. Only three have a usable numeric duration in the worksheet. Two duration cells look empty, and several other entries need inspection. Before writing “three tickets” or “eight measured,” decide what each number answers.
A count can tell you how many cells contain numeric measurements, how many carry some content, or how many records satisfy a condition. These are three distinct questions. A team can have eight ticket IDs and only three numeric times. If it divides those three recorded times by eight, it will silently treat missing measurements as if they contributed zero. Counts make it possible to detect that mistake before computing the average.
All example records, times and thresholds in this lesson are made up. The names of apps help identify the scenario. The code and reports describe no real operating process at Swiggy, Blinkit or Amazon Now.
Distinguish COUNT, COUNTA and COUNTBLANK
COUNT observes numeric cells
For a worksheet range, =COUNT(B2:B9) reads its cells and counts those with numeric values. Numeric zero counts. A number produced by a formula counts. A date stored as an Excel date also counts because Excel represents it with a number, even if the display uses words for a month. If a delivery-duration column accidentally contains an actual date, COUNT may include it. You still need a separate rule to validate whether a numeric value is a plausible number of minutes.
In a range, COUNT ignores text, logical values and error values. A visible 12 may be text when the entry has an apostrophe before it, or when an export supplied the figure as text. =ISNUMBER(B6) helps distinguish a true numeric value from a string that looks numeric. Excel has special behavior for certain literals entered directly as COUNT arguments. The worksheet rules here use ranges deliberately so that the difference between a cell value and an argument typed into a formula stays visible.
COUNTA observes stored content
Use =COUNTA(A2:A9) for a column of text IDs when each intended record carries one identifier. COUNTA also counts numbers, logical values, errors and cells containing formulas that return empty text. It observes content, including content Excel displays as blank. As a result, eight populated cells can still include a repeated ID, a space or an error. Treat the result as an occupancy check before testing the intended meaning of the entries.
COUNTBLANK observes empty cells and empty text results
Use =COUNTBLANK(B2:B9) when you need to count blank cells and formula results of empty text. The formula ="" returns a text value with zero characters. It contributes to COUNTBLANK. A formula returning one space has one character, even though the sheet may look empty, so it does not contribute to COUNTBLANK. Numeric zero does not count as blank even when a display setting hides zero values.
Lab 1 · Investigate three cells that look blank
Create a scratch worksheet named Tickets. Put Ticket ID in A1 and Duration (mins) in B1. The small dataset includes intentionally awkward values. Enter these only in the practice workbook so that a formula error or a weak-looking result is part of the exercise and easy to reverse.
| Cell | Ticket ID in A | Enter in B | COUNT | COUNTA | COUNTBLANK |
|---|---|---|---|---|---|
| B2 | SW-201 | 14 | Yes | Yes | No |
| B3 | SW-202 | 0 | Yes | Yes | No |
| B4 | SW-203 | Leave it empty | No | No | Yes |
| B5 | SW-204 | ="" | No | Yes | Yes |
| B6 | SW-205 | '12 | No | Yes | No |
| B7 | SW-206 | =" " | No | Yes | No |
| B8 | SW-207 | =1/0 | No | Yes | No |
| B9 | SW-208 | =2+5 | Yes | Yes | No |
Measure three different properties
- In E2 enter
=COUNT(B2:B9). B2, B3 and B9 count. Expect three. B3 is the numeric zero case. B9 is a formula whose evaluated result is numeric. - In E3 enter
=COUNTA(B2:B9). Every cell except B4 has content. Expect seven. The division error counts as occupied even though you cannot use it as a duration. - In E4 enter
=COUNTBLANK(B2:B9). B4 and B5 count. Expect two. B7 has a space, so it belongs only in the occupancy count even though it can look blank. - In C1 type Physically empty? and in C2 enter
=ISBLANK(B2). Fill through C9. Only C4 should display TRUE.=COUNTIF(C2:C9,TRUE)returns one. This check asks a different question from COUNTBLANK because the formula in B5 is stored content. - In E5 enter
=COUNTA(A2:A9). It returns eight for the ticket IDs. Compare it with E2's three numeric durations. You can now report that three out of eight tickets have numeric duration values in this fixture. You still need a policy about the plausibility of a true zero-duration record.
Look at B6 from the formula bar and test =ISNUMBER(B6). It returns FALSE. You can compare it with writing =COUNT("12") directly in a spare cell, which returns one for the numeric-looking literal placed in the argument list. That special literal behavior does not turn the text value at B6 into a numeric measurement. Base report checks on the stored input range.
Repair the known data problems and predict each change
The first lab deliberately stores faulty entries. Before you edit them, note the four baseline counts: eight rows with IDs, three numeric timings, seven occupied duration cells and two blank duration results. Knowing which counts should change makes it much easier to identify whether the repair changed content, its type or both.
- Convert the verified text timing. In this exercise the source confirms that the visible 12 in B6 really means twelve minutes. Re-enter it as numeric 12. The numeric count rises to four. The occupancy and blank counts do not move because B6 had content before and still has content afterward.
- Replace the test error with a known duration. In the fictional lab, B8's verified duration is ten. Re-enter it as numeric 10. The numeric count becomes five. The occupancy count still reads seven and the blank count is still two. A different row could require fixing the formula instead of replacing it, so choose the action using the source.
- Clear the formula in B5. It already displayed empty text. After the formula is cleared, the cell is physically empty. COUNTA drops to six. COUNTBLANK remains two because B5 contributed to it in both states. There are now two physically empty cells.
- Clear the space formula in B7. Removing the one-character result brings COUNTA to five and COUNTBLANK to three. The numeric count remains five. The status of B7 changed from stored empty-looking content to no content.
Use the classifications to describe what you actually improved. The first two edits supplied more usable timings. The last two edits helped the workbook represent missing values consistently. No change touched the eight ticket IDs. If you were publishing data completeness, you could say five tickets have numeric durations and three remain without a measurement. These are data quality categories and depend on the business definition of a valid duration.
Move from a type count to a condition
Put away the scratch ticket worksheet and use the ten-row chapter Orders sheet. Here the measurements are already numeric and every row has a city and status. Start with a condition you can trace manually. =COUNTIF(C2:C11,"Pune") counts four order rows. The range is City. The criterion is that its value matches Pune. Every match contributes one, regardless of amount or quantity.
Use one criterion at a time
- With text, quote the label.
=COUNTIF(I2:I11,"Delivered")gives seven on this dataset.=COUNTIF(I2:I11,"Cancelled")gives two, and a separate Returned count gives one. - With a plain numeric equality, use the value as the criterion. For example,
=COUNTIF(H2:H11,12)gives one. This data has exactly one order at twelve minutes. - With a comparison and constant together, use quotes.
=COUNTIF(H2:H11,">12")gives five. The combined greater-than sign and twelve are the test sent to Excel. - With an editable boundary, join the operator to a cell using the ampersand. Put 12 in K2, then use
=COUNTIF(H2:H11,">"&K2). Typing K2 inside the quoted text would hide the actual cell reference from the formula.
Add another condition using COUNTIFS
In =COUNTIFS(I2:I11,"Delivered",H2:H11,">12"), the first pair checks the status and the second pair checks minutes. Both tests must hold for the same position in their respective ranges. A returned order with a longer time would still fail the status. A delivered order at exactly twelve still fails the strict time test. This gives four on the ten-row worksheet.
COUNTIFS takes range and criterion pairs from the beginning. There is no separate sum range. The ranges do not need to be beside each other, but they do need the same dimensions and, in your report, must begin and end on the same order records. An equal-size range shifted by one row can compare the status of one order with the minutes of the next.
Count four orders with two tests
Open the strict time test
Rows with minutes over twelve are 4, 6, 8, 10 and 11. At this stage the status is unrestricted. The count is five.
Check status at the same positions
Row 10 is Cancelled. Its thirteen minutes still pass the time test. The status criterion removes it from the delivered group.
Look for the boundary record
Row 3 was Delivered and took exactly twelve minutes. It remains outside the strict time count. The qualifying rows are still 4, 6, 8 and 11.
Count one per matching row
There are four matching orders. Some have more than one item. This measure counts each matching row once and ignores its Qty.
Lab 2 · Build a delivery-count and cancellation report
Use the original Orders data and create results in spare columns K and L. Put labels next to every result. In this exercise ten order IDs are present and distinct, so a count of the identifier field can act as the denominator for rates defined over all listed orders. In another dataset, check that assumption before copying the formula.
Check ordinary counts first
- Use
=COUNT(G2:G11)to get ten numeric amounts.=COUNTA(A2:A11)gives ten populated IDs.=COUNT(A2:A11)gives zero because these specific IDs are text. - Use
=COUNTBLANK(I2:I11)to check for blank status results. The original data gives zero. Count Delivered, Cancelled and Returned separately. Their counts are seven, two and one. Together they account for each row because the fixture uses one of those statuses for every order. - Use
=COUNTIF(C2:C11,"Pune")for all Pune orders. It returns four. Add Delivered using=COUNTIFS(C2:C11,"Pune",I2:I11,"Delivered"). It returns three. Check which one fails status and which row numbers are retained.
Compare the rule boundary and an editable input
- Put 12 in K2, and enter
=COUNTIF(H2:H11,">"&K2)in L2. Expect five. On the next line use=COUNTIFS(I2:I11,"Delivered",H2:H11,">"&K2). Expect four. The extra status condition drops the cancelled row. - Set K2 to 15. Expect three orders above fifteen minutes, and all three are delivered. Verify the durations sixteen, eighteen and seventeen. Restore twelve.
- In a third comparison, change the greater-than operator to greater than or equal to. The all-status count becomes six and the delivered count becomes five. The new qualifying record is the same Nashik order on row 3 in both tests.
- To count Pune orders taking ten minutes or less, combine the Pune condition with
"<=10"on the minutes range. The result is two, from rows 2 and 7. Prove both times and the city before you add another criterion.
Compute an interpretable rate
Use =COUNTIF(I2:I11,"Cancelled")/COUNTA(A2:A11). Under this fixture's definition the numerator is cancelled orders and the denominator is all ten listed orders. The result is 0.2. Format it as a percentage to display 20%. Label it Cancelled share of all listed orders so a reader knows the Returned order is still in the denominator.
Temporarily change I10 from Cancelled to Delivered. Cancelled count falls from two to one. Cancelled share becomes 10%. Delivered count rises from seven to eight, and the delivered count above twelve rises from four to five. Total IDs and the all-status count above twelve remain unchanged. Restore the original status and verify that the expected totals return.
Count text patterns and alternatives deliberately
Read the shape of the label
An asterisk in a COUNTIF or COUNTIFS criterion allows any sequence of characters, including none. A question mark matches a single character. For the order sheet, =COUNTIF(C2:C11,"Na*") gives three: two Nashik orders and one Nagpur order. The prefix should describe the intended group. If a new city starting with Na is added, its rows can enter the count too.
Use a tilde immediately before a wildcard to match the actual symbol. Imagine a small practice inventory for a seller listing on Amazon. In an unused column, enter the three labels BAG-1, BAG-12 and BAG-?. A criterion of "BAG-?" counts two of these codes because each has exactly one character following the hyphen. "BAG-~?" finds only the literal question-mark code. If you expected to find a particular ID, test the criterion on at least one neighboring code to make sure its pattern has the necessary limits.
COUNTIF's ordinary criteria ignore case. For instance, typing a criterion of Pune or PUNE checks the same city letters in this use. A trailing space, an extra punctuation mark or a different city spelling can still change what matches. If case identifies distinct codes in a source, use a method designed for a case-sensitive comparison such as EXACT in a helper column. Do a one-row test before applying it to the full list.
Count either option while accounting for overlap
When every row has one status, “Cancelled or Returned” can be counted by adding two separate matches. In the original Orders sheet, these groups are disjoint and their counts add to three. In contrast, “Pune or Delivered” has an overlap. There are four Pune orders and seven delivered orders, with three in both groups. Adding four and seven gives eleven entries because the three overlapping records counted twice. Subtract those three once to reach eight distinct qualifying rows.
A COUNTIFS call with two criteria joins them by requiring both. It gives the overlap count of three here. If the policy eventually has several alternatives, use a separate per-row decision so that each qualifying record is marked once, then count the marks. Read the lessons on IF and OR before you build a broader rule.
Distinguish rows, populated cells and unique records
The lab's order ID column contains one text value on each row. The reason COUNTA appears useful there is that the source was checked. If you apply it to a status note column or an incomplete export, the number can have a different meaning. Choose the field that provides the evidence the report needs.
Interpret each count independently
- Rows in a range.
=ROWS(A2:A11)returns ten because the reference covers ten row positions. It answers a structural question even if some of those cells have no value. - Populated identifiers.
=COUNTA(A2:A11)reports ten occupied ID cells in this worksheet. If someone clears one ID, it drops to nine even though the range still contains ten row positions. - Distinct identifiers. If someone duplicates one ID in another filled row, COUNTA can still return ten. A distinct count should combine equal IDs into one item. Use a dedicated distinct-list approach appropriate for your Excel version and check for blank IDs separately.
- Number of units. If the report asks how many products were ordered, add the Qty column. One order with Qty 5 still counts as one record with COUNTIFS. It contributes five to a sum of units.
Find one duplicate without altering the source
In an expendable copy, replace A11 with the existing ID from A2. Place =COUNTIF($A$2:$A$11,A2) in a helper cell on row 2 and fill down through row 11. This counts appearances of each row's current ID. Rows 2 and 11 should both show two because they now hold the same code. All other IDs still show one. The initial ID occupancy count stays ten. This simple helper identifies where to inspect an import; it is counting occurrences, so both copies are marked. Restore A11 after the check.
A duplicated identifier may represent a bad import or a legitimate change in the record structure. Some exports use one row per item, so several rows can intentionally share an order ID. Ask what one row means before deleting anything. A quantity-by-order report may need to group those records, while a record-availability report may legitimately count every row.
Diagnose a count before changing its formula
A count that is different from your expectation is often useful evidence about the inputs or scope. It can also expose a condition that does not match the report label. Start by asking which individual cell or row should count and verifying what Excel actually sees.
- The count dropped in a numeric field. Check a known missing record with ISNUMBER. A duration might be a number stored as text, or a formula could currently return blank text. Correct the stored representation only when you know the intended source value.
- A blank-looking cell was counted as occupied. Read its formula bar. Use ISBLANK to identify a physically empty cell, and inspect for a space or empty text returned by a formula. The screen's appearance alone does not give you the correct classification.
- A condition count unexpectedly gives zero. Manually identify a record that should pass and check its spelling, both boundaries and source ranges. Confirm the expression uses the intended criteria cell. COUNTIFS can treat a reference to an empty criteria cell as zero, so fill the intended threshold or require a valid control value before accepting the result.
- The count changed after filling down. Read the references in the first and last formulas. Fix the population ranges with absolute references if they should stay the same. Leave a summary's criterion relative if it should follow each row in the summary.
- The count disagrees with a filtered screen. The ordinary range-based counters here refer to the stated cells even if a sheet filter hides rows. Use
=SUBTOTAL(102,H2:H11)to check visible numeric durations, or 103 in a separate SUBTOTAL for occupied ID cells. These function numbers exclude filtered-out and manually hidden rows. Verify the effect by filtering Orders to Delivered in a copy. With these complete numeric minutes and complete ID cells, both visible counts should give seven. - A row was added below the source. Inspect the membership of the range or table. A fixed range ending on row 11 cannot count a new row 12. If you switch to table columns, verify that the new record became a table row.
Count usable entries with a business rule
Return to the Tickets scratch sheet from Lab 1 after its repairs. Five durations are numeric and three cells are physically empty. Suppose the classroom exercise defines a recorded duration as a number from zero through 120 minutes. That range is a fictional validation rule for this workbook. A real team would derive its valid ranges from what the source measures and how it measures it.
Use a separate classification result
Put Duration check in D1. Each record should receive one of three labels. Empty cells get Missing. Values that are present but fail the type or limits get Check. Numeric values that fit the limits get Usable. A named label with one purpose makes it possible to count the outcome with COUNTIF and review individual records.
In D2 use the following exercise formula. Read it through the first condition before using the rest. Nested IF is covered in depth later. The outer IF first checks whether the referenced cell has no content. If it has content, the next test checks its type. Only when the value is numeric does the inner rule compare its limits. An error or text input should get Check without asking the numeric comparisons to operate on it.
=IF(ISBLANK(B2),"Missing",IF(ISNUMBER(B2),IF(AND(B2>=0,B2<=120),"Usable","Check"),"Check"))
- Fill the expression through D9 on the repaired data. Expect five Usable, three Missing and zero Check labels. A simple
=COUNTIF(D2:D9,"Usable")gives the usable count. Change the criterion for the other two outcomes. - Change B9 from seven to 121 in your practice copy. The numeric count still gives five. The usable count drops to four and the Check count increases to one. This proves why the type check alone cannot enforce your allowed domain.
- Test the two permitted endpoints in B9. Zero and 120 both give Usable. Try minus one and confirm Check. Then restore the original formula calculating seven in B9.
- Type the formula returning empty text back into B5. It is visibly blank, but this rule returns Check because the cell has content and Excel does not see a number. Decide whether a blank-looking formula should instead count as Missing in your use case, and change the classification rule deliberately if so. Clear B5 again after the test.
- Temporarily return B8 to the deliberate division error. It is present and fails the numeric type test, so its label is Check. Restore its verified value of ten minutes. Check that the final three outcome counts still add to the eight ticket records.
A classification can help with other data, including fields that permit a valid exception. One team might distinguish a Cancelled ticket from a missing duration instead of treating both as an input problem. Add the status condition first if it changes whether the field applies at all. Document the meaning of each label so a report reader does not confuse “unusable today” with “missing from the source.”
Keep the denominator visible when you share a rate
Imagine the fictional shift report reports two cancellations. The rate is 20% when divided by ten listed orders. If a teammate defined its denominator as only delivered and cancelled orders, they would divide by nine and get about 22.22%. The difference is not a rounding issue. The second definition deliberately excludes the Returned order. A reader cannot compare the rates until both reports state their populations.
- Show the actual numerator and denominator next to the displayed rate. In a very small sample, changing one record can move a percentage by ten points. Keeping the count visible gives the reader perspective.
- Give an empty population its own outcome. When there are zero eligible orders, the percentage is undefined under an ordinary numerator-over-denominator definition. If the report owner wants a specific message, use an explicit condition and test it against an empty sample.
- Check the same date and category filters for both pieces of the rate. Counting cancelled Pune orders and dividing by all cities would answer a different question from the share cancelled within Pune.
- Use an ID count only when the record field is complete for the population. Duplicate or missing identifiers can make one entry per cell an inaccurate count of distinct orders. Check the expected row structure first.
As a final practice task, calculate the cancelled share within Pune. The numerator has one order, the denominator has four, and the result is 25%. The overall cancelled share remains 20%. Write both labels next to their results. If the report is shared with context missing, those labels still tell someone which comparison they are seeing.
Check that status groups cover the report
A status count can reconcile with the total very easily when the sample is clean. Make two deliberate changes to see why matching counts matter. In a scratch copy of Orders, clear I9. It used to say Returned. The identifier remains present, and Delivered and Cancelled remain seven and two. Returned drops to zero. The three status counts now add to nine. An additional COUNTBLANK on I2:I11 finds the missing status. You have evidence that a group is incomplete without assuming the order record itself disappeared.
Restore Returned and then temporarily add a space at the end of that word in I9. The cell contains text and its blank check returns no missing status. An exact text criterion for Returned still misses the extra character. Try comparing the length of the stored value with the length of the expected label. The expected word has eight letters. The modified value has nine characters. Restore the original value after the check.
Now choose the checks you would keep on the finished report. Track the number of expected order IDs. Count the statuses you intentionally recognize. Compare the sum of those groups with the ID count and report any difference. When the difference is positive, inspect which records have an unknown or missing state. If it is negative, look for overlapping conditions that can count a record twice. This logic uses the premise that every order has exactly one expected status.
Include one explicit “status awaiting confirmation” state if the source considers it meaningful. That gives those orders a named group and protects the denominator. A good report lets a reader tell which rows have a completed process, which are still being checked, and which have missing source values.
Quiz · choose the right counter
Eight text IDs are present, and only three durations are numeric. Which count represents recorded numeric timings?
COUNT over the duration range gives three. COUNTA over the ID range gives eight occupied identifiers. Each count is valid for its stated field and criterion.
How does a formula returning empty text affect COUNTA and COUNTBLANK?
Both include its cell. COUNTA sees stored content and COUNTBLANK includes the empty text result. A physically empty cell contributes to COUNTBLANK and is omitted by COUNTA.
Does numeric zero belong in the blank count?
No. A stored zero is numeric. It contributes to COUNT and COUNTA even if display settings make it visually inconspicuous. Blank handling needs a separate policy from a zero display.
How many delivered orders took strictly more than twelve minutes?
Four orders. Rows 4, 6, 8 and 11 pass both conditions. Row 3 has exactly twelve and row 10 was cancelled. Each fails one part of the rule.
What does "BAG-~?" match in the three-code example?
It matches the literal question-mark code. The tilde tells Excel to treat the next character as text. Without the tilde, the one-character suffix can match the one-digit code too.
An order ID is duplicated, and all ten ID cells remain occupied. What happens to COUNTA?
It still counts ten occupied cells. A duplicate reduces the number of distinct identifiers, which is a different measure. Check occurrences in a helper column if you need to locate the duplicated rows.
Interview practice · explain the reason for each count
When would you use COUNT rather than COUNTA?
I would use COUNT for numeric measurements such as recorded durations. I would use COUNTA for occupied ID or note cells. I would verify a text-looking number with ISNUMBER when the two counts differ in a field expected to be numeric.
Why can a cell be both occupied and blank for Excel functions?
A cell with a formula has stored content. Its evaluated result can be an empty string. The two counters measure different properties, so their results can overlap. ISBLANK can help me check whether the input cell is physically empty.
What would you check in a COUNTIFS result that looks one too high?
I would identify the qualifying rows and inspect conditions near their boundaries. A greater-than-or-equal-to sign may include a row at the threshold. I would also confirm that both source columns describe the same record at each range position.
How would you verify a cancellation rate?
I would count cancellations using the stated status and independently count the total eligible orders. When the report says all orders, include all recorded statuses in the denominator. I would test whether changing a relevant status moves the numerator and preserves the total population.
Can COUNTIF tell you the number of unique customer IDs?
For a given ID, it can count how often that ID appears. A distinct count requires combining all repeated IDs into one item each. I would also check whether ID cells are missing before presenting a distinct count as complete.
Six cards to recall before counting a report
- COUNT Numeric cells in the reference count, including numeric zeros and numeric formula results.
- COUNTA Occupied cells count, including text, errors and formulas that return empty text.
- COUNTBLANK Physically empty cells and empty text results count. A literal space or zero does not.
- COUNTIF Test one range against one criterion. Each match contributes one.
- COUNTIFS Test aligned range positions. Count one when every tested condition holds.
- Record audit Identify the unit, range and eligible population. Check duplicates and missing values before using a denominator.
Continue with averages and conditional extremes, or read the short COUNTIF and COUNTIFS guide. The existing print cards explain the basic counters, one condition, and multiple conditions in their own small examples.
Microsoft references
Continue practising: explore the existing Excel Task Hub for additional exercises.