Function · Math

Excel SUMIF function

The Excel SUMIF function adds numbers whose neighbor cells pass one test. A grocery-category example that totals $198.57.

All current Excel versions. Also in Excel for the web and Google Sheets.

Syntax =SUMIF(range, criteria, [sum_range])

SUMIF
=SUMIF(A2:A4,"Groceries",B2:B4)

Arguments

NameRequiredWhat to pass
rangeRequiredThe cells to test, such as the category column.
criteriaRequiredThe test. A word such as Groceries, or a comparison in quotes such as ">100".
sum_rangeOptionalThe numbers to add. If omitted, range itself is added. It should be the same shape as range.

Examples

Two grocery trips

=SUMIF(A2:A4,"Groceries",B2:B4)

Result $198.57

=SUMIF(A2:A4,"Groceries",B2:B4)B5
Categories
AB
1CategoryAmount
2Groceries86.40
3Rent1900
4Groceries112.17
5Grocery total198.57
A picture of the sheet, not a live calculator. 86.40 + 112.17 = 198.57.

SUMIF adds a number only when a neighbor passes one test. The test range and the number range are separate arguments, and the number range is last. That order is the reverse of SUMIFS, which is the usual reason a formula that used to work breaks after a second condition is added.

The two grocery rows are $86.40 and $112.17, so the category total is $198.57. Rent is in the same block and is left out. The same layout, with a date test added, is the monthly budget in the how-to. Use SUMIFS once you have more than one condition. SUMIF cannot express “groceries and November” in a single criteria argument.