How to Fix Division-by-Zero Error in Excel PivotTable Calculated Fields
Question details
The user needs to resolve a division-by-zero error when calculating averages in an Excel PivotTable calculated field.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Attempting to evaluate averages in a PivotTable where the denominator is a count of items, which can include blanks or complex Data Model relationships.
- Observed behavior
- The standard calculated field formula fails or returns a #DIV/0! error because the denominator incorrectly evaluates to zero under certain PivotTable conditions.
Ensure your source data is formatted as an official Excel Table (Ctrl+T) and verify that the Power Pivot add-in is enabled if you plan to use Data Model measures.
Create a Power Pivot Measure using the DIVIDE Function
Bypassing standard calculated fields and using the Data Model allows you to use the DAX DIVIDE function, which safely handles division by zero automatically.
Standard PivotTable calculated fields often struggle with averages when the denominator relies on a count of rows, especially if blanks are present. Loading your data into the Data Model and creating a custom DAX measure is the most reliable way to perform this calculation without generating errors.
Select your source data table, go to the Insert tab, click 'PivotTable', and check the box that says 'Add this data to the Data Model' before clicking OK.
In the PivotTable Fields pane, right-click your table name at the top of the field list and select 'Add Measure'.
Name your measure (e.g., Average Story Points). In the formula box, enter `=DIVIDE(SUM(Data[Story Points]), COUNTA(Data[Work item type]))`. Be sure to replace 'Data' with your actual table name and adjust the column names accordingly.
If you only want to count numeric values in the denominator rather than all non-empty cells, change 'COUNTA' to 'COUNT' in your DAX formula.
Click OK to save the measure. Locate the new measure in your PivotTable Fields list (indicated by an 'fx' icon) and drag it into the Values area.

Use IFERROR in a Standard Calculated Field
If you are not using the Excel Data Model, you can wrap your standard calculated field formula in an IFERROR function to suppress the division-by-zero error.
Switch to WPS Office for Simplified Data Analysis
If troubleshooting complex Data Models and DAX measures in Microsoft Excel is slowing down your workflow, consider using WPS Spreadsheet. It offers a lightweight, highly compatible alternative for everyday data analysis, featuring intuitive PivotTable tools that are easy to master without a steep learning curve.

Frequently Asked Questions
Why does a PivotTable Calculated Field show a #DIV/0! error?
This error occurs when the calculation's denominator evaluates to zero or is blank. In standard calculated fields, calculations are performed on the sum of the underlying data rather than row-by-row, which can sometimes result in an unexpected zero denominator when grouping data.
What is the difference between COUNT and COUNTA in DAX measures?
COUNT only counts rows where the specified column contains numeric values. COUNTA counts any non-empty cell in the column, including text, logical values, and numbers. Choosing the correct function ensures your denominator accurately reflects the intended dataset.
Can I visually hide division errors in a PivotTable without changing the formula?
Yes. Right-click anywhere in the PivotTable and select 'PivotTable Options'. Under the 'Layout & Format' tab, check the box for 'For error values show:', and leave the adjacent text box blank or enter a zero. This masks #DIV/0! errors globally for that specific PivotTable.




