How to Calculate Median While Ignoring #DIV/0! Errors in Excel
Question details
The user needs to find the median value of a dataset containing AVERAGEIFS results without the #DIV/0! errors breaking the calculation.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating statistical median values on ranges that occasionally return division by zero errors due to underlying conditional formulas.
- Observed behavior
- Standard MEDIAN functions fail and return a #DIV/0! error when the source range contains error values.
Ensure you know the exact range of cells you want to calculate the median for. Double-check that your data is formatted as numbers to ensure accurate calculation.
Use the AGGREGATE Function to Ignore Errors
The AGGREGATE function is the most efficient method to calculate statistics like the median while automatically ignoring any error values in the data range.
The AGGREGATE function allows you to apply various statistical calculations while conditionally skipping hidden rows and error values. By using the QUARTILE.INC operation (function number 17) and requesting the 2nd quartile, you effectively calculate the median.
Click on the empty cell where you want the median result to be displayed.
Type the formula =AGGREGATE(17,6,C4:C88,2). Replace 'C4:C88' with the actual range containing your data and #DIV/0! errors.
Press Enter. Excel will calculate the 2nd quartile (the median) while bypassing any cells containing errors.

Use an Array Formula with MEDIAN and IF
If you are using an older version of Excel that does not support the AGGREGATE function, you can use a combination of MEDIAN and IF enclosed in an array formula.
Easily Handle Complex Formulas with WPS Spreadsheet
WPS Spreadsheet fully supports advanced functions like AGGREGATE and array formulas, allowing you to calculate medians and ignore errors effortlessly. It provides a lightweight, intuitive environment for all your data analysis needs.
- 1. Open your data file: Launch WPS Spreadsheet and open the workbook containing your dataset.
- 2. Select the target cell: Click on the cell where the median result should be placed.
- 3. Apply the AGGREGATE formula: Type =AGGREGATE(17,6,your_range,2) and press Enter to instantly see your error-free result.

Frequently Asked Questions
Why does my median formula return a #DIV/0! error?
The standard MEDIAN function cannot bypass errors on its own. If even one cell in your referenced range contains a #DIV/0! error (often caused by dividing by zero in other cells), the entire MEDIAN formula will inherit and output that error.
Can I use function number 12 in AGGREGATE for the median instead?
Yes, for a simple range. However, function number 12 (MEDIAN) only supports reference arguments and does not handle nested array evaluations. Using function 17 (QUARTILE.INC) with the 2nd quartile is a highly reliable workaround because it allows array-form evaluations while perfectly calculating the median.
Will this formula ignore other errors like #N/A or #VALUE!?
Yes. The AGGREGATE function with option 6 ignores all error types, including #N/A, #VALUE!, #REF!, and #DIV/0!. The formula will automatically bypass these cells and calculate the median from the remaining valid numbers.




