Skip to content

SUMIFS Function in Excel

Math · Updated

Purpose
Add up the numbers in a range where every one of several conditions is true.
Returns
A number. 0 if no row meets all the conditions.
Syntax
fx=SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], …)
Works in
Excel 2007 and later · Microsoft 365 · Google Sheets · LibreOffice Calc

Arguments

ArgumentRequiredWhat it is
sum_rangeYesThe cells to add up. In SUMIFS this comes first.
criteria_range1YesThe first range to test. It must be the same size as sum_range.
criteria1YesThe condition for the first range. A number, a cell reference, or text in double quotes such as "Travel" or ">=100".
criteria_range2, criteria2NoMore range and condition pairs, up to 127 pairs in total. A row is added only when it passes every condition.

Example: total one expense category in one month

A row is added to the total only when its month in column A equals E2 and its category in column B equals F2. Two rows pass both tests.

G2fx=SUMIFS(C2:C7, A2:A7, E2, B2:B7, F2)
ABCDEFG
1MonthCategoryAmountMonthCategoryTotal
2JanTravel320FebTravel655
3JanOffice145
4FebTravel410
5FebMeals88
6FebTravel245
7MarTravel500

Build your SUMIFS formula

Fill in the fields with your own cells. The formula updates as you type.

Optional.
Optional. Both conditions must be true.
Your formula
E2fx=SUMIFS(C2:C20, A2:A20, "East", B2:B20, ">100")

Adds up C2:C20 for rows where A2:A20 meets "East" and B2:B20 meets ">100".

Paste the formula into cell E2 or any empty cell. The coloured parts match the coloured fields. Using a different list separator? Replace the commas with semicolons.

How SUMIFS works

SUMIFS checks your data row by row. For each row it tests the first criteria range against the first condition, the second range against the second condition, and so on. If every test passes, the value from the sum range on that row is added to the total. If any test fails, the row is skipped.

That makes SUMIFS an AND function. Month is Feb and category is Travel. There is no built-in way to say “or” between conditions.

The sum range is the first argument. This is the reverse of SUMIF, where the column to add up comes last:

Function Order of arguments
SUMIFS sum_range, criteria_range1, criteria1, …
SUMIF range, criteria, [sum_range]

After the sum range, arguments come in pairs: a range, then the condition for that range.

Writing the criteria

Each condition follows the same rules as in SUMIF. Numbers and cell references need no quotes. Text and comparison operators go inside double quotes.

Criteria Matches
"Travel" Cells equal to Travel. Case is ignored.
">300" Numbers greater than 300.
"<>Jan" Cells that are not equal to Jan.
"*east*" Text that contains “east” anywhere.
">="&E1 Values greater than or equal to the value in E1.
"" Blank cells.
"<>" Cells that are not blank.

Join an operator to a cell reference with &. The wildcards are * for any text and ? for one character. Put a tilde before either one, as in "~?", to match the character itself.

More examples

The first three use the example data above, with months in column A, categories in column B and amounts in column C.

A text condition and a number condition

=SUMIFS(C2:C7, B2:B7, "Travel", C2:C7, ">300")

returns 1230, the total of the three Travel amounts over 300. The sum range can also be a criteria range.

Exclude a value

=SUMIFS(C2:C7, A2:A7, "<>Jan", B2:B7, "Travel")

returns 1155, the Travel total for every month except Jan.

Either of two categories

=SUM(SUMIFS(C2:C7, B2:B7, {"Office","Meals"}))

returns 233. SUMIFS produces one total per category in the list, and SUM adds them.

Between two dates

=SUMIFS(C2:C100, A2:A100, ">="&E1, A2:A100, "<="&F1)

returns the total of column C for rows dated from the date in E1 to the date in F1, both included.

Tips

  • Every range must be the same size and shape. A mismatch returns #VALUE!.
  • Lock the ranges with dollar signs ($C$2:$C$7) and leave the criteria cells relative, so the formula can be copied across a summary table.
  • Put the conditions in cells and refer to them, as the example does with E2 and F2. Changing the report then needs no formula edit.
  • SUMIFS ignores text in the sum range. Numbers stored as text add up to 0.
  • Two conditions on the same column are fine when both can be true, such as a lower and an upper bound. Two different exact values on one column always give 0.
  • A condition can be on the sum range itself, as in the first example above.

SUMIFS or SUMIF

Use SUMIFS when you have two or more conditions. Use either function when you have one.

SUMIF works in every version of Excel, and SUMIFS needs Excel 2007 or later, which covers almost every file in use today. Many people write SUMIFS for single conditions too. The formula is then ready for a second condition, and there is only one argument order to remember.

If you switch a formula from one function to the other, move the sum range. =SUMIF(A2:A7, "Feb", C2:C7) becomes =SUMIFS(C2:C7, A2:A7, "Feb").

To count the rows that meet several conditions, use COUNTIFS, which takes the same range and condition pairs without a sum range. For a formula written from a plain description, try the Excel formula generator.

Errors and fixes

ErrorWhy it happensFix
#VALUE!A criteria range is a different size from the sum range, for example C2:C7 and A2:A8.Give every range the same first and last row.
0 resultNo row passes every condition. Two different values asked of the same column, such as Travel and Meals, can never both be true.Check each condition alone. For either-or logic, add two SUMIFS formulas together.
0 or wrong totalThe arguments are in SUMIF order, with the sum range last.Move the column to add up to the first position.
#VALUE!The formula refers to ranges in another workbook that is closed.Open the other workbook, or copy the data into the same file.

Questions

What is the difference between SUMIF and SUMIFS?

SUMIF tests one condition. SUMIFS tests one or more and adds a row only when all of them are true. The argument order is different too. SUMIFS starts with the sum range: (sum_range, criteria_range1, criteria1, …). SUMIF ends with it: (range, criteria, sum_range).

Can SUMIFS do OR logic?

Not inside one set of conditions, because every condition must be true. Add two formulas together, or pass a list of values and sum the results: =SUM(SUMIFS(C2:C7, B2:B7, {"Office","Meals"})).

How do I sum between two dates with SUMIFS?

Test the date column twice: =SUMIFS(C2:C100, A2:A100, ">="&E1, A2:A100, "<="&F1), with the start date in E1 and the end date in F1.

Why does SUMIFS return #VALUE!?

The ranges are not the same size. Every criteria range must have the same number of rows and columns as the sum range. The error also appears when the formula points at a closed workbook.

Why does SUMIFS return 0?

No row met all the conditions at once. Common causes are trailing spaces in the data, numbers stored as text in the sum range, and two conditions on one column that cannot both be true.

Is SUMIFS case-sensitive?

No. "travel" and "Travel" match. Wildcards work in text conditions: an asterisk for any text and a question mark for one character.

Related