The short answer: you can use COUNTA in a pivot table, but it works differently than a regular worksheet formula. In a pivot table, COUNTA appears as a value field calculation (Count) that counts non-empty cells, and you enable it by dragging a field into the Values area and choosing Count (or Count Numbers). You don’t type a formula; you select the aggregation in the Value Field Settings.
What COUNTA Actually Counts
In a standard Excel worksheet, =COUNTA(A1:A10) counts cells that are not empty, including text, numbers, errors, and even formulas that return an empty string (“”). It ignores truly blank cells. In a pivot table, the equivalent is the Count value field setting, which counts all non-empty cells in the source data column for each row/column group. The pivot table’s Count does exactly what COUNTA does: it counts text and numbers alike.
This is different from Count Numbers, which only counts numeric cells (like COUNT in a worksheet). If your data column contains a mix of text and numbers, Count will include both; Count Numbers will only include the numeric ones.
How to Add COUNTA to a Pivot Table
Steps (Excel for Microsoft 365 on Windows; same on Mac and Excel for the web unless noted):
- Select any cell in your source data and go to Insert > PivotTable.
- In the PivotTable Fields pane, drag the column you want to count (e.g., Customer Name) into the Values area.
- By default, Excel may show Sum of Customer Name if the column is numeric, or Count of Customer Name if it’s text. To change it, click the drop-down arrow next to the field name in the Values area, then select Value Field Settings.
- Under Summarize value field by, choose Count (not Count Numbers). Click OK.
If you want the count to appear as a percentage of the total, you can also right-click a value in the pivot and choose Show Values As > % of Grand Total.
Why You Can’t Write =COUNTA() Inside a Pivot Table
Pivot tables are not formula-driven in their data area. You can’t type =COUNTA(B2:B100) into a pivot cell because the pivot table’s layout is dynamic—rows and columns change as you filter or refresh. Instead, you must use the built-in aggregation. If you need a custom calculation that references pivot values, you can add a calculated field (PivotTable Analyze > Fields, Items & Sets > Calculated Field), but that only works with numeric operations like SUM or AVERAGE, not COUNTA. For counting, the built-in Count is the correct tool.
Common Problems and Fixes
- Pivot shows Sum instead of Count: This happens when the column contains numbers. Right-click the field in Values > Value Field Settings > choose Count.
- Count is counting blanks: Pivot tables ignore blank cells in the source data for Count by default. If you have cells with spaces (which look blank), they are counted. Use
=TRIM()on the source column to remove spaces, or filter out those rows. - Count is too high: If your source data has duplicate rows, Count counts each row. Use Distinct Count (available in Excel 2013 and later) by adding the data to the Data Model (check “Add this data to the Data Model” when creating the pivot). Then in Value Field Settings, choose Distinct Count.
- Text field shows as “Count of…” but you wanted numbers: That’s correct for COUNTA. If you need numeric sum, use a different column or change the field type in source.
COUNTA vs. Count Numbers vs. Distinct Count
These three settings answer different questions:
- Count (COUNTA): How many rows have any value in this column? (Text or number)
- Count Numbers: How many rows have a numeric value? (Ignores text)
- Distinct Count: How many unique values are in this column? (Ignores duplicates)
Example: If you have a column with values {Apple, 5, Apple, , 7}, Count returns 4, Count Numbers returns 2, Distinct Count returns 3 (Apple, 5, 7).
Using COUNTA in Google Sheets Pivot Tables
Google Sheets pivot tables work similarly. When you add a field to Values, the default is usually COUNTA for text fields and SUM for numeric fields. To change it, click the field in the Values section, then select Summarize by > COUNTA. Google Sheets also offers COUNT (numbers only) and COUNTA (non-empty). For distinct count, you need to use a helper column or a pivot table with a calculated field using =COUNTUNIQUE() in the source data.
Frequently Asked Questions
Can I use COUNTA in a pivot table calculated field?
No. Calculated fields only allow numeric operations like SUM, AVERAGE, COUNT (which is actually COUNTA in that context), and PRODUCT. You cannot write a formula that counts text within a calculated field. Use the built-in Count value field instead.
Why does my pivot table show “Count of” instead of “Sum of”?
Because the column you dragged to Values contains text, or because Excel automatically chose Count when the column has any blank cells. To force Sum, right-click the field, go to Value Field Settings, and choose Sum if the data is numeric. If the data is text, Sum is not possible; you need a numeric column.
How do I count unique values in a pivot table?
Use the Distinct Count option. When creating the pivot table, check “Add this data to the Data Model.” Then in Value Field Settings, select Distinct Count. This is available in Excel 2013 and later, and in Excel for Microsoft 365.
Does COUNTA count cells with formulas that return blank?
In a worksheet, yes—COUNTA counts cells containing formulas that return an empty string (“”). In a pivot table, the Count aggregation also counts such cells because they are not truly empty. If you want to exclude them, you need to clean the source data (e.g., replace formulas with blanks).
Can I use COUNTA in a pivot table to count checkboxes?
If your checkboxes are linked to cells with TRUE/FALSE, COUNTA will count both TRUE and FALSE because they are non-empty. To count only TRUE, use a helper column with =IF(A2=TRUE,1,"") and then use Sum on that helper column, or use Count on a column that only contains values for checked items.
Related
- Advanced SQL Queries for Interview: 9 Patterns
- Random Number Generator Between Two Numbers
- Auto Sum Shortcut in Excel: Quick Keys & Steps
Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.
More in Charts & pivot tables
- Excel Waterfall Chart Subtotals: How to Set ThemTo show a subtotal in an Excel waterfall chart, select its bar, right-click, and choose Set as Total.…
- How to Make a Flow Chart in Word Online: Step by StepTo make a flow chart in Word Online, open a document, choose Insert > Shapes, draw and label…
- Excel Pivot Table Filter Multiple Values: Quick GuideTo filter a PivotTable to several values in Excel for Microsoft 365 on Windows, open the drop-down for…
- Excel Pivot Table Months Not in Order? Fix the DatesIf Excel PivotTable months are out of order, first check whether the source column contains real dates or…
- Excel Chart Average Line: Add and Format the MeanTo add an average line to an Excel chart, calculate the mean in a worksheet cell, repeat that…
- Adding an Excel Chart to PowerPoint: Link, Embed, or CopyTo add an Excel chart to PowerPoint, select the chart in Excel and press Ctrl+C, switch to PowerPoint,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.