How to Prevent a Divide-by-Zero Error with AVERAGEIFS in Excel
Question details
The user needs to handle or prevent the #DIV/0! error that occurs when the AVERAGEIFS function yields no matching numeric values.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating conditional averages across a dataset where certain criteria combinations might result in zero matching records or target blank cells.
- Observed behavior
- Excel displays a #DIV/0! error in the cell rather than leaving it blank or returning a zero.
Verify that your selected data range contains valid numbers and double-check your criteria spelling to ensure the #DIV/0! error is genuinely caused by a lack of matching records.
Wrap the AVERAGEIFS formula in an IFERROR function
Use the IFERROR function to intercept the #DIV/0! error and replace it with a clean fallback value, such as a blank cell, zero, or custom text.
The AVERAGEIFS function calculates the mathematical average of cells that meet multiple specified criteria. Because an average is calculated by dividing the sum of values by the count of those values, a count of zero mathematically results in a division by zero. Excel flags this as a #DIV/0! error.
By utilizing IFERROR, you can instruct Excel to display an alternative result whenever the formula encounters any error, making your spreadsheets cleaner and preventing downstream formula calculation failures.
Click on the cell containing your AVERAGEIFS formula or the cell where you intend to write it.
In the formula bar, type =IFERROR( to initiate the error-handling wrapper.
Place your complete AVERAGEIFS formula inside the first argument of the IFERROR function. For example: AVERAGEIFS(average_range, criteria_range1, criteria1).
Add a comma after the AVERAGEIFS formula, then type your desired fallback value. Use "" for a blank cell, or 0 to return a zero.
Close the parentheses. The final formula should look like this: =IFERROR(AVERAGEIFS(C2:C10, A2:A10, "Complete"), ""). Press Enter to apply.

Calculate Conditional Averages Effortlessly with WPS Spreadsheet
WPS Spreadsheet fully supports advanced logical functions like AVERAGEIFS and IFERROR, allowing you to build complex, error-free reports. It features a built-in formula wizard to help you construct nested functions easily.
- 1. Open your dataset: Launch WPS Spreadsheet and open your existing .xlsx or .csv workbook.
- 2. Use the Function Wizard: Select your target cell, go to the 'Formulas' tab, and click 'Insert Function'.
- 3. Nest your formulas: Search for and select 'IFERROR'. In the 'Value' field, type your AVERAGEIFS formula.
- 4. Set the fallback: In the 'Value_if_error' field, enter "" or 0, then click OK to execute.

Frequently Asked Questions
Why exactly does AVERAGEIFS return a #DIV/0! error?
AVERAGEIFS returns this error when the specific criteria you set match exactly zero cells in your dataset. Because an average requires dividing the sum of matching cells by the count of matching cells, dividing by a count of zero creates a mathematical divide-by-zero anomaly.
Can I use IF and COUNTIFS instead of IFERROR?
Yes. You can use a formula like =IF(COUNTIFS(criteria_range, criteria)>0, AVERAGEIFS(...), ""). This method counts the matches first and only calculates the average if there is at least one match. While it is highly specific to the empty criteria scenario, IFERROR is generally shorter and easier to write.
Will IFERROR hide other mistakes in my AVERAGEIFS formula?
Yes, IFERROR catches all error types, including #VALUE!, #N/A, and #NAME?. If you have a typo in your formula or invalid range sizes, IFERROR will suppress those errors and output your fallback value. It is recommended to test your AVERAGEIFS formula alone first to ensure it works properly before wrapping it in IFERROR.
What is the best alternative value to return when no criteria are met?
The best value depends on your use case. Use "" (empty string) for visual reports where you want uncluttered cells. Use 0 if the cell result is part of larger numerical calculations (like grand totals). You can also use descriptive text like "No Data" to explicitly inform users that no records matched the query.




