Sub topic 17
Troubleshooting wrong totals and errors
This chapter assumes you can enter and copy formulas, understand relative and absolute references, and have already written SUMIFS, COUNTIFS, and AVERAGEIFS formulas with text, operator, wildcard, date, and blank criteria. Here you learn to find out why one of those formulas returns an error or a number you don't trust.
A method for diagnosing a bad result
Most problems fall into a few groups. Work through them in order, because the early checks are fast and catch most mistakes.
- Read the error value, if there is one. It points to a specific cause.
- Check that every range has the same shape.
- Check that each criterion means what you think it means.
- Check that the data itself is what it looks like (text versus numbers, stray spaces, real dates).
- Compare the result with a manual check, such as a filter and the status bar total.
Errors and what they mean
| Result | Usual cause | Fix |
|---|---|---|
| #VALUE! | Ranges differ in size or shape, or a range points to a closed workbook | Make every range the same number of rows and columns |
| #DIV/0! | AVERAGEIFS found no matching rows | Wrap in IFERROR, or test with COUNTIFS first |
| #NAME? | Misspelled function, or a table or name that does not exist | Check spelling and defined names |
| 0 | No rows match, or the criteria do not match the data as stored | Check text, spaces, and data types |
| Total is too small | Numbers stored as text, wrong date logic, or an exclusive boundary | Convert data types and review operators |
| Total is too large | An OR built by double counting, or criteria that are too loose | Tighten criteria and check wildcards |
Notice that SUMIFS and COUNTIFS rarely show an error when criteria fail to match. They return 0, which looks valid. That makes silent wrong answers more dangerous than visible errors.
#VALUE! from mismatched ranges
Every range argument must have the same number of rows and columns. The sample data lives in rows 2 to 100, so these ranges are aligned.
=SUMIFS(D2:D100, B2:B100, "West")This version fails because the criteria range is one row longer.
=SUMIFS(D2:D100, B2:B101, "West")The result is #VALUE!. This often happens after you insert rows or edit one reference by hand and forget the others. Another cause is the same size in a different shape, such as D2:D100 against B2:C100.
A related trap is a mismatch that does not produce an error because it is the sum range, not the criteria range, that has a different starting row. Excel only checks that the dimensions match. If you write D3:D101 as the sum range and B2:B100 as the criteria range, the formula works without an error but pairs each Region with the Amount from the next row. The total is wrong and no message tells you. Keep the first row of every range identical.
#DIV/0! from AVERAGEIFS
AVERAGEIFS divides a total by a count. When no row matches, the count is zero.
=AVERAGEIFS(D2:D100, B2:B100, "South")The sample data has no South rows, so this returns #DIV/0!. Replace the error with readable text.
=IFERROR(AVERAGEIFS(D2:D100, B2:B100, "South"), "No sales")One caution: IFERROR hides every error, including #VALUE! from a range mismatch. If the formula is large, test the cause directly instead.
=IF(COUNTIFS(B2:B100, "South")=0, "No sales", AVERAGEIFS(D2:D100, B2:B100, "South"))This only masks the no-match case and lets a real error appear.
Criteria that look right but match nothing
When SUMIFS returns 0, the problem is usually in the text of the criterion or in the data.
- Hidden spaces. A cell holding
"West "with a trailing space does not equal"West". Use a helper column with=TRIM(B2)or clean the source data. A wildcard such as"West*"also catches the trailing space. - Non-breaking spaces. Text pasted from web pages can contain character 160, which TRIM does not remove. Use
=SUBSTITUTE(B2, CHAR(160), " ")and then TRIM. - Wrong operator syntax. An operator must be inside quotes and joined to a cell value with
&.
=SUMIFS(D2:D100, B2:B100, "West", D2:D100, ">=" & G1)Writing ">=G1" searches for the literal text "G1". Writing >=G1 without quotes is a syntax error.
- Case. Matching ignores letter case, so case is never the cause.
- Wildcard characters in the data. If the data contains a real
*or?, put a tilde in front of it in the criterion, for example"~*".
Numbers stored as text
A number that is stored as text may look like a number, but it is left-aligned and often shows a green triangle. Criteria such as ">=1000" cannot compare against text amounts, so those rows are skipped. SUMIFS also ignores text in the sum range. Your total is too small and no error appears.
To check, compare these two results.
=COUNT(D2:D100)
=COUNTA(D2:D100)COUNT counts only true numbers. COUNTA counts every non-empty cell. If COUNTA is larger than the number of data rows with amounts, some entries are text. Fix them with Text to Columns, by multiplying the column by 1 in a helper column, or with =VALUE(D2).
Date problems
Dates are numbers, but imported dates are often text. A date criterion only works on real dates. Check with =ISNUMBER(A2). If it returns FALSE, the date is text.
For a month, use a start date that is inclusive and an end date that is exclusive.
=SUMIFS(D2:D100, A2:A100, ">=" & DATE(2025,1,1), A2:A100, "<" & DATE(2025,2,1))Using "<=" & DATE(2025,1,31) works only when the dates carry no time portion. If a cell holds 2025-01-31 14:30, that value is greater than January 31 at midnight and drops out of the total. The exclusive upper bound avoids this.
Too-large totals and double counting
Wildcards can match more than you intended. "Lap*" matches Laptop and also Lapel. If you build OR logic by adding SUMIFS formulas, make sure the values do not overlap.
=SUMIFS(D2:D100, B2:B100, "West") + SUMIFS(D2:D100, B2:B100, "East")This is safe because one row has only one Region. It would double count if the two criteria could both match one row, such as "W*" and "West". For two conditions on different fields, an addition is wrong and you need to subtract the overlap or use another approach (see the next chapter on alternatives).
Verifying a result
Do not trust a formula only because it returns a number. Check it.
- Apply an AutoFilter with the same conditions.
- Select the visible Amount cells and read the Sum and Count in the status bar.
- Compare with the formula. Both must agree.
For a formula you will copy across a summary grid, also test one corner cell by hand. If a copied formula drifts, look at its anchors.
=SUMIFS($D$2:$D$100, $B$2:$B$100, $G2, $C$2:$C$100, H$1)If the data ranges lack $, they shift as you copy and silently cover the wrong rows. Press F2 on a copied cell to see the colored range outlines and confirm they still cover rows 2 to 100.
Using an Excel table avoids this class of error. Structured references always cover the whole column and grow with new rows.
=SUMIFS(Sales[Amount], Sales[Region], "West")Exercise
This formula returns 0 although the sheet clearly has West rows with amounts over 1000: =SUMIFS(D2:D100, B2:B100, "West", D2:D100, ">=G1") where G1 contains 1000. Name the error in the formula and write the corrected version.
Show answer
The operator and the cell reference are inside one quoted string, so Excel compares against the literal text "G1" instead of the value in G1. Join them with &: =SUMIFS(D2:D100, B2:B100, "West", D2:D100, ">=" & G1)
Exercise
A SUMIFS total for January misses sales that happened on January 31 after noon. The formula uses "<=" & DATE(2025,1,31) as the upper bound. Why, and how do you fix it?
Show answer
Those cells contain a time portion, so their value is greater than January 31 at midnight. Use an exclusive upper bound on the first day of the next month: "<" & DATE(2025,2,1).
Exercise
COUNT(D2:D100) returns 96 and COUNTA(D2:D100) returns 99, yet all 99 rows have an amount. What is wrong, and what effect does it have on SUMIFS?
Show answer
Three amounts are stored as text. COUNT counts only true numbers, and SUMIFS ignores text in the sum range, so the total is too small without any error. Convert the three cells to numbers.