SUMIFS, and the Argument Order That Flips
About this lesson
SUMIFS adds the cells in one range where every condition in the pairs that follow holds. The range to add is named first. Each condition is joined by and.
- total rows that match two or more conditions with SUMIFS.
- say why SUMIFS puts the numbers first and SUMIF puts them last.
The idea
The plural form takes the range to add first, then as many range-and-condition pairs as you need. That is the reverse of SUMIF. The reversal has a reason: with up to 127 conditions allowed, the one argument that appears exactly once has to sit somewhere fixed.
Every pair is joined by and. There is no way to ask for W1 or W2 in one call. So the right answer to an or-question is two SUMIFS added together. Excluding is easy, though. A condition beginning <> means everything except.
The mistake to watch for
Carrying SUMIF's order into SUMIFS. SUMIFS puts the range to add first, then pairs of range and condition. That is the opposite of SUMIF. The wrong order tests the wrong column and returns 0 with no error. Write the plural form for everything, and the order stops mattering.
Where this comes up again
This lesson needs JavaScript to run. Everything below is the lesson in full, but you cannot type into the grid or be marked.
Start with what you know.
In E2, type =SUMIF(A2:A8,"Dara O",D2:D8) to total Dara's hours: test the names, match Dara, add the hours.
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Employee | Week | Project | Hours | |||
| 2 | Dara O | W1 | Harbour | 22 | Dara, SUMIF | ||
| 3 | Dara O | W2 | Harbour | 18 | Dara, SUMIFS | ||
| 4 | Sam L | W1 | Harbour | 31 | Dara in W2 | ||
| 5 | Sam L | W2 | Ferry Road | 24 | Dara, W2, Harbour | ||
| 6 | Dara O | W2 | Ferry Road | 12 | Harbour over 20 | ||
| 7 | Nia P | W1 | Ferry Road | 27 | Everything but Harbour | ||
| 8 | Nia P | W2 | Harbour | 9 |
Every step
-
Start with what you know. In
E2, type=SUMIF(A2:A8,"Dara O",D2:D8)to total Dara's hours: test the names, match Dara, add the hours. -
SUMIFSdoes the same job with the order flipped. The range to add comes first, then pairs of range and condition. InE3, type=SUMIFS(D2:D8,A2:A8,"Dara O")and get the same 52. -
Now the reason
SUMIFSexists: a second pair. InE4, total Dara's hours in weekW2only. Add the weeks column andW2as a second pair. -
Read
=SUMIFS(D2:D8,A2:A8,"Dara O",B2:B8,"W2",C2:C8,"Harbour")and say what it returns: Dara, inW2, on Harbour. -
A condition can be a comparison. A range can appear twice: once as the range added, once tested. In
E6, total the Harbour hours from the entries longer than 20 hours. Test ">20" against the hours themselves. -
A condition can also exclude. "<>Harbour" means anything other than Harbour. In
E7, write a formula usingSUMIFSthat totals the hours booked to anything other than Harbour.