Sub topic 3
SUMIFS: adding values that meet conditions
SUMIFS adds the values in one column, but only for rows where every condition you set is true. This chapter covers its argument order, how it reads the sample data, how conditions combine, and the mistakes that most often produce wrong totals.
Prerequisites
This chapter assumes you can do the following:
- Enter a formula in Excel and copy it to other cells.
- Tell relative references (
D2) from absolute references ($D$2). - Use SUM, COUNT, and AVERAGE on a range.
- Work with data laid out in rows and columns, with a header in row 1.
The sample data
All examples use the same sales layout. Headers are in row 1, and data runs from row 2 down to row 100.
A: Date B: Region C: Product D: Amount E: Notes
2025-01-05 West Laptop 1200
2025-01-09 East Monitor 300 Backorder
2025-02-02 West Monitor 310
2025-02-14 North Laptop 1150 GiftThe ranges stop at row 100 so the formulas have room for more rows than the four shown. Empty rows below the data do not change the result of a SUMIFS.
The argument order
SUMIFS takes the range to add first. After that come one or more pairs of a criteria range and a criteria.
SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)sum_rangeis the column of numbers to add.criteria_range1is the column that Excel tests.criteria1is the condition that a cell in the criteria range must meet.
Here is the simplest case. It totals Amount for rows where Region is West.
=SUMIFS(D2:D100, B2:B100, "West")With the four sample rows, Excel checks B2 through B100 for the text West. It finds West in the first and third rows, so it adds 1200 and 310 from the same rows of column D. The result is 1510.
The older SUMIF function puts the sum range last, and its sum range is optional. SUMIFS always puts the sum range first. If you switch between the two, check the order every time.
How conditions combine
Each additional pair narrows the result. SUMIFS joins all pairs with AND, so a row counts only when every pair is true. Adding a second pair can lower the total but never raise it.
The next formula adds Amount only for West rows where the product is a Laptop.
=SUMIFS(D2:D100, B2:B100, "West", C2:C100, "Laptop")On the sample data this returns 1200. The row for West Monitor fails the second pair, so Excel skips it.
You can use the same column in more than one pair. This is how you set both ends of a range, as in the date example below.
Operators inside criteria
A criteria that is plain text or a number tests for equality. To test for something else, put the comparison operator at the start of a quoted string. The operators are >, <, >=, <=, and <> (not equal to).
=SUMIFS(D2:D100, D2:D100, ">=1000")Here the sum range and the criteria range are the same column. That is allowed. It adds every Amount of at least 1000.
To read the threshold from a cell, join the operator and the cell value with &. In this formula, G1 holds the minimum amount.
=SUMIFS(D2:D100, B2:B100, "West", D2:D100, ">=" & G1)The operator stays inside quotes, and the & attaches the number from G1. If G1 contains 1000, Excel reads the criteria as ">=1000". Changing G1 changes the result without editing the formula.
Date ranges
Dates are stored as numbers, so the same operators work on them. Use the same date column in two pairs to set a start and an end.
=SUMIFS(D2:D100, A2:A100, ">=" & DATE(2025,1,1), A2:A100, "<" & DATE(2025,2,1))This totals all of January 2025. The end condition is "less than 1 February", which keeps every time on 31 January and drops nothing. Writing "<=" & DATE(2025,1,31) can miss entries that carry a time of day, because a value such as 31 January at 14:00 is larger than 31 January at midnight.
Use DATE() instead of typing a date as text. A text date can be read differently depending on the regional settings of the computer that opens the file.
Wildcards and blanks
In text criteria, * matches any run of characters, and ? matches exactly one character. Matching ignores letter case. To add all amounts for products that start with Lap, write the following.
=SUMIFS(D2:D100, C2:C100, "Lap*")To find a literal * or ? in the data, put ~ in front of it, as in "~*".
An empty string criterion matches blank cells, and "<>" matches cells that are not blank. This formula adds West amounts where the Notes column is empty.
=SUMIFS(D2:D100, B2:B100, "West", E2:E100, "")On the sample data it returns 1510, because neither West row has a note.
OR logic across values
Conditions in one SUMIFS are combined with AND. A single row has only one region, so asking for West and East in the same function returns 0. For OR across values of one field, add two SUMIFS results.
=SUMIFS(D2:D100, B2:B100, "West") + SUMIFS(D2:D100, B2:B100, "East")An array constant makes this shorter. The curly braces hold a list of criteria. SUMIFS returns one total per value, and SUM adds them.
=SUM(SUMIFS(D2:D100, B2:B100, {"West","East"}))Both forms return 2010 on the sample data (1200 + 310 for West, plus 300 for East). The array form is easier to maintain when the list is long, but the list is typed into the formula.
Mistakes that give wrong totals
| Symptom | Likely cause | Fix |
|---|---|---|
| `#VALUE!` | Ranges have different sizes | Make every range the same number of rows and columns |
| Result is 0 but matches exist | Numbers stored as text, or extra spaces in the data | Convert the text to numbers, or clean the cells with TRIM |
| Total ignores some rows | The range stops before the last data row | Extend the ranges or use a table |
| Total is too large or small | A date end condition uses `<=` on values with times | Use `<` with the day after |
| Operator treated as text | Operator and number written as one string with the cell name | Write `">=" & G1`, not `">=G1"` |
Range size is the most common cause of #VALUE!. D2:D100 with B2:B99 fails, even though the mistake is one row. The ranges do not need to start on the same row number in a different sheet, but they must have the same shape.
Tables and copyable formulas
If the data is an Excel table named Sales, structured references replace fixed ranges and grow when you add rows.
=SUMIFS(Sales[Amount], Sales[Region], "West")To build a grid of regions down the side and products across the top, lock the data ranges and mix the anchors on the criteria cells. Place regions in G2 downward and products in H1 across. This formula can be copied across and down.
=SUMIFS($D$2:$D$100, $B$2:$B$100, $G2, $C$2:$C$100, H$1)$G2 keeps the column fixed while the row changes. H$1 keeps the row fixed while the column changes.
Exercise
Using the sample layout, write a SUMIFS formula that adds Amount for rows where Region is West and Amount is at least the value in cell G1. Then say what the formula returns if G1 contains 1250.
Show answer
=SUMIFS(D2:D100, B2:B100, "West", D2:D100, ">=" & G1). With G1 = 1250, no West row has an Amount of 1250 or more (the West amounts are 1200 and 310), so the result is 0.
Exercise
A colleague's formula =SUMIFS(D2:D100, B2:B99, "West") returns #VALUE!. What is wrong, and how do you fix it?
Show answer
The criteria range B2:B99 has 98 rows, while the sum range D2:D100 has 99. The ranges must be the same size. Change the criteria range to B2:B100.