AVERAGEIFS Returns #DIV/0! When Nothing Matches

AVERAGEIFS returns #DIV/0! when no numeric values match, while SUMIFS and COUNTIFS return 0. A matched score of zero is a real average, not an error.

本文目錄

AVERAGEIFS returns #DIV/0! on a grade that “should” have an average, while SUMIFS and COUNTIFS using the same criterion return 0. The criterion is not necessarily broken. A sum or a count can be zero when nothing matches; an average has nothing to divide by.

These results, and the error text quoted later, were measured in Google Sheets. I did not re-check in Excel whether AVERAGEIFS also returns #DIV/0!, so treat any Excel wording as unconfirmed.

Six functions, one missing grade

Enter this fictional community climbing-gym route-score log in A1:D10. Leave D6 genuinely empty. In D7 enter ="". In D8 enter a numeric 0. Use Automatic number formatting.

RouteGradeWallScore
Y-12V2North80
Y-14V2North90
Y-17V3South70
Y-19V3South90
Y-21V4East
Y-23V5East
Y-25V6West0
Y-27V2West100
Y-29V3North80

There are no V7 routes. =COUNTIFS(B2:B10,"V7") returns 0. The same criterion across six functions, measured in Google Sheets:

FunctionFormulaResult
AVERAGEIFS=AVERAGEIFS(D2:D10,B2:B10,"V7")#DIV/0!
AVERAGEIF=AVERAGEIF(B2:B10,"V7",D2:D10)#DIV/0!
SUMIFS=SUMIFS(D2:D10,B2:B10,"V7")0
COUNTIFS=COUNTIFS(B2:B10,"V7")0
MAXIFS=MAXIFS(D2:D10,B2:B10,"V7")0
MINIFS=MINIFS(D2:D10,B2:B10,"V7")0

The AVERAGEIFS message is Evaluation of function AVERAGEIFS caused a divide by zero error. AVERAGEIF uses the same wording with AVERAGEIF in the name. A 0 from SUMIFS, COUNTIFS, MAXIFS or MINIFS does not mean that matching scores exist.

Google Sheets cell G2 showing #DIV/0! for AVERAGEIFS of grade V7, with a hover titled Error that reads Evaluation of function AVERAGEIFS caused a divide by zero error, and a Fix button.
Screenshot: Google Sheets, Nov 2026

The hover uses a red Error heading and includes a Fix button; I did not click Fix. I did not re-check the Excel message on a Mac; treat any Excel wording as unconfirmed. For other zero denominators, see how to fix #DIV/0! errors. If you expected a nonzero sum, see why SUMIF and SUMIFS return zero.

Matching routes don’t always have numeric scores

Change the criterion to V2. =COUNTIFS(B2:B10,"V2") returns 3, and =AVERAGEIFS(D2:D10,B2:B10,"V2") returns 90 — the mean of 80, 90 and 100. V3 averages to 80.

Grades that do have a row, but not a usable score, are a different case:

GradeCOUNTIFSAVERAGEIFSScore in the log
V41#DIV/0!a genuine blank in D6
V51#DIV/0!, same message="" in D7
V610numeric 0 in D8
Google Sheets results in G8 and G9: AVERAGEIFS of grade V6, whose score is 0, returns 0, while AVERAGEIFS of grade V4, a blank score, returns #DIV/0!.
Screenshot: Google Sheets, Nov 2026

COUNTIFS counts matching rows, not numeric scores. A recorded zero is a real average. A blank or an empty string is not, and AVERAGEIFS still divides by zero. To count only matching rows that have a number:

=SUMPRODUCT(--(B2:B10="V4"),--ISNUMBER(D2:D10))

That returns 0 for V4 and 1 for V6. ISNUMBER excludes blanks and empty strings without excluding a numeric zero.

Criteria that quietly exclude every row

If COUNTIFS is already 0, AVERAGEIFS will be #DIV/0! for the same reason as V7. Two mismatches that look equal on the grid behaved differently in Sheets.

A text 02 in F2 and a numeric 2 in H2, both displayed as 02 (the number used a 00 format), were treated as a match: =COUNTIFS(F2:F2,H2) returned 1, and =AVERAGEIFS(G2:G2,F2:F2,H2) returned 85. Do not assume a leading-zero lookalike is a mismatch in Google Sheets.

A trailing space is a mismatch. With V2 (length 3) as the criterion, =COUNTIFS(B2:B10,J2) returned 0 與 =AVERAGEIFS(D2:D10,B2:B10,J2) returned #DIV/0! with the same divide-by-zero message.

Wildcards can also empty the set, or do the opposite. =COUNTIFS(B2:B10,"*") returns 9, and =AVERAGEIFS(D2:D10,B2:B10,"*") returns approximately 72.85714286, the mean of the seven numeric scores (80, 90, 70, 90, 0, 100 and 80). The asterisk matches every text grade. A typo such as "W*" matches nothing: COUNTIFS returns 0 and AVERAGEIFS returns #DIV/0!.

Return a label instead of hiding the error

Put V7 in E2. I would test for matching rows before averaging:

=IF(COUNTIFS(B2:B10,E2)=0,"No matching routes",AVERAGEIFS(D2:D10,B2:B10,E2))

That returns No matching routes for V7 and 0 for V6. It leaves the missing-score #DIV/0! visible for V4 and V5, which is what I want when a blank score is a problem to fix.

If missing scores are normal in the log, distinguish those too:

=IF(COUNTIFS(B2:B10,E2)=0,"No matching routes",IF(SUMPRODUCT(--(B2:B10=E2),--ISNUMBER(D2:D10))=0,"No numeric scores",AVERAGEIFS(D2:D10,B2:B10,E2)))

That returns No matching routes for V7, No numeric scores for V4 and V5, 0 for V6, and 90 for V2.

=IFERROR(AVERAGEIFS(D2:D10,B2:B10,E2),"No average") also returns No average for V7, V4 and V5, but it hides unrelated errors such as a broken reference or a mismatched range. See IFERROR vs IFNA for that difference. For a climbing-gym report, I would keep the two labels separate: a grade with no routes is not the same as a grade whose routes have not been scored. \n

Oscar

寫 Excel 與 Google Sheets 的公式和排錯。

Google Sheets, 26 November 2026, new private unshared spreadsheet (locale en_US, 1000-row grid, America/New_York). Formulas were entered as user input through the Sheets API. Error text was read from the Sheets API error message (type DIVIDE_BY_ZERO). Climbing-gym sample A1:D10; D6 blank, D7 ="", D8 numeric 0. COUNTIFS of V7 returned 0. AVERAGEIFS and AVERAGEIF of V7 returned #DIV/0!, "Evaluation of function AVERAGEIFS caused a divide by zero error." (AVERAGEIF names AVERAGEIF). SUMIFS, COUNTIFS, MAXIFS and MINIFS of V7 each returned 0. COUNTIFS of V2 returned 3; AVERAGEIFS of V2 returned 90. AVERAGEIFS of V3 returned 80. V4 (blank score): COUNTIFS 1, AVERAGEIFS #DIV/0!, same message. V5 (empty string): COUNTIFS 1, AVERAGEIFS #DIV/0!. V6 (score 0): COUNTIFS 1, AVERAGEIFS 0. SUMPRODUCT of V4 with ISNUMBER returned 0; of V6 returned 1. Text 02 versus numeric 2 (displayed 02): COUNTIFS returned 1 and AVERAGEIFS returned 85 (Sheets did match them). COUNTIFS of a trailing-space V2 against the Grade column returned 0; AVERAGEIFS returned #DIV/0!, same message. COUNTIFS of "*" returned 9; AVERAGEIFS of "*" returned 72.85714286 (not 70). COUNTIFS of "W*" returned 0; AVERAGEIFS returned #DIV/0!. IF(COUNTIFS=0, No matching routes, AVERAGEIFS) returned that label for V7, 0 for V6, and #DIV/0! for V4. The nested IF with SUMPRODUCT/ISNUMBER returned No matching routes for V7, No numeric scores for V4 and V5, 0 for V6, and 90 for V2. IFERROR(AVERAGEIFS, No average) returned No average for V7, V4 and V5. Excel was not run.

本主題下一篇:表格錯誤與動態陣列 Straight-Line Depreciation Formula in Excel and Sheets