SUMIF Sums the Wrong Column: The Argument Order Is Not SUMIFS
SUMIF is (range, criterion, sum_range); SUMIFS starts with the sum range. Reusing SUMIFS order in SUMIF can return #N/A or 0.
On this page
You wanted “sum Amount where Region is East” and got #N/A, or a 0 that you blamed on the data. The East rows are still there. The usual cause is that SUMIF was written in SUMIFS order.
The two functions do not take their arguments the same way:
SUMIF(range, criterion, [sum_range])
SUMIFS(sum_range, criteria_range, criterion, ...)
SUMIFS puts the column to add first. SUMIF puts the column to test first, and the column to add last. That last argument is optional. If you paste a SUMIFS layout into SUMIF, Amount and Region swap roles. These results were measured in Google Sheets. I did not re-run the formulas in Excel.
This is not the text-number zero, where Amount looks numeric and SUMIFS still returns 0. That case is SUMIF Returns 0 Despite Matching Rows.
One sample, three outcomes
Enter this in A1:C10. Amounts are ordinary numbers.
| Region | Product | Amount |
|---|---|---|
| East | Binder | 140 |
| West | Binder | 85 |
| East | Tray | 260 |
| North | Binder | 45 |
| East | Clip | 30 |
| West | Tray | 150 |
| South | Clip | 70 |
| East | Tray | 55 |
| North | Clip | 10 |
East is four rows: 140 + 260 + 30 + 55 = 485.
Working SUMIFS — sum range first:
=SUMIFS(C2:C10,A2:A10,"East")
Working SUMIF — criteria range first, sum range last:
=SUMIF(A2:A10,"East",C2:C10)
Both returned 485.
Now the two layouts people get when they reuse SUMIFS order:
=SUMIF(C2:C10,A2:A10,"East")
=SUMIF(C2:C10,"East",A2:A10)
The first one is SUMIF(Amount, Region-range, "East"). The criterion is a range, and the optional sum range is the text "East". In this file that formula returned #N/A: “Argument must be a range.”
The second one is SUMIF(Amount, "East", Region). It looks for the text East inside the Amount column, then would add values from Region. No Amount equals East, so the result was 0. That 0 is easy to blame on the data.
Two arguments only: SUMIF adds the criteria range itself
=SUMIF(C2:C10,">100")
With no third argument, SUMIF sums the cells in C2:C10 that are greater than 100: 140 + 260 + 150 = 550 (two East rows and one West row). This is valid. It is just not “sum Amount where Region is East.”
When the order bug and the type bug stack
On a copy of the table, enter the last East Tray amount in C9 as text: type a leading apostrophe and 55. ISNUMBER(C9) is FALSE and ISTEXT(C9) is TRUE.
=SUMIF(A2:A10,"East",C2:C10)
=SUMIFS(C2:C10,A2:A10,"East")
Both totals dropped from 485 to 430, because SUMIF and SUMIFS skip text in the sum range, with no error. That short total is the type bug, and it is easy to stack on top of a swapped-argument 0 or #N/A. Fix the argument order first, then convert the text amounts. The conversion methods are on SUMIF Returns 0 Despite Matching Rows.
A criterion built from a cell
Put 100 in E1. The operator stays inside quotes; the number is joined with &:
=SUMIF(C2:C10,">"&E1)
=SUMIFS(C2:C10,A2:A10,"East",C2:C10,">"&E1)
The first formula is the two-argument form again, and it also returned 550. It does not become a Region filter just because E1 sits next to the table. The SUMIFS form is “East, and Amount greater than the value in E1,” and it returned 400 (140 + 260; 30 and 55 are left out). If you write ">=DATE(...)" as a single quoted string, that is a different 0, covered in SUMIFS between two dates.
Related: COUNTIF vs COUNTIFS vs SUMPRODUCT for the same criteria-range-first habit in COUNTIF, and SUMIFS OR in the same column when a second criterion was meant as OR, not AND.
Sources
- Microsoft Support: SUMIF function (argument order;
sum_rangeoptional): https://support.microsoft.com/en-us/office/sumif-function-169b8c99-c05c-4483-a712-1697a6531397 - Microsoft Support: SUMIFS function (sum_range is the first argument): https://support.microsoft.com/en-us/office/sumifs-function-8862c7d6-46b9-4d0e-8b46-0b4c9e5b12b2
- Google Docs Editors Help: SUMIF: https://support.google.com/docs/answer/3093583
- Google Docs Editors Help: SUMIFS: https://support.google.com/docs/answer/3093584