FxFormula Drills

SUMIF examples

SUMIF adds a column of numbers where a related cell meets one condition. SUMIF(region, "East", amount) is the East total. SUM adds every number, with no condition. SUMIFS is the function to switch to when a row must pass two or more tests, and its arguments come in a different order.

Syntax

SUM

SUM(range)

Adds every number in the range. Text and blank cells are ignored. There is no criteria argument.

SUMIF

SUMIF(range, criteria, [sum_range])

range is tested against criteria. sum_range is what gets added, and it must line up with range. If you omit sum_range, Excel adds the cells in range that match. A text criterion and a comparison such as ">10" go in quotes.

SUMIFS

SUMIFS(sum_range, criteria_range1, criteria1, ...)

The range to add comes first. Each extra pair is another test, and a row has to pass all of them. That order is the reverse of SUMIF.

Comparison

QuestionSUMSUMIFSUMIFS
ConditionsNoneOneOne or more, combined with AND
Argument orderThe numbers onlyTest range, then criterion, then the numbersNumbers first, then pairs of range and criterion
OR logicNot applicableAdd two SUMIF results, or use a wildcard when the pattern fitsAdd two SUMIFS results
WildcardsNoYes. * is any text, ? is one characterYes, in a text criterion
VersionsEvery current Excel and Google SheetsEvery current Excel and Google SheetsExcel 2007 and later, and Google Sheets

Worked examples

East sales

Column A is the region and column C is the amount. East appears on three rows: 10, 30, and 20. The West row, 40, stays out.

Four orders. Three of them are East.
RowABC
1RegionProductAmount
2EastPen10
3WestPen40
4EastBook30
5EastPen20
  • =SUM(C2:C5) → 100
  • =SUMIF(A2:A5,"East",C2:C5) → 60
  • =SUMIFS(C2:C5,A2:A5,"East",B2:B5,"Pen") → 30

SUM of the amount column is 100, every order. SUMIF keeps the rows whose region is East and adds 10+30+20. SUMIFS adds a second test, product Pen, so Book's 30 drops out and the total is 10+20. Notice the amount range moved to the front in SUMIFS.

A wildcard for product names

Pen should match and Book should not. A criterion of P* means text that starts with P. The asterisk is any number of characters after that.

Same orders. Products are Pen, Pen, Book, and Pen.
RowABC
1RegionProductAmount
2EastPen10
3WestPen40
4EastBook30
5EastPen20
  • =SUMIF(B2:B5,"P*",C2:C5) → 70

The three Pen amounts are 10, 40, and 20, which add to 70. Book does not start with P, so 30 is excluded. Put the wildcard inside the quotes. A criterion stored in a cell can be the text P* as well, and the formula becomes SUMIF(B2:B5, E1, C2:C5) if E1 holds P*.

When to use which

Use SUM when every row counts

A column of monthly figures with no category to filter is SUM. The free sales drill is that case: four numbers, one total.

Use SUMIF for a single test

One region, one product, one threshold, or one wildcard. SUMIF is the right size. You can compare with ">100" or "<>East" using the same quotes.

Move to SUMIFS as soon as there is a second test

Region and product together are SUMIFS. Do not nest SUMIF. The multiple-criteria page covers AND, and the pattern of adding two SUMIFS calls when you mean OR.

Common mistakes

Swapping the ranges

SUMIF(C2:C5, "East", A2:A5) tests the amounts for the word East and then adds the region labels. The total is 0. The range you test is the range that contains East.

Ranges of different lengths

A2:A5 tested against C2:C4 leaves the last amount unpaired. Keep the test range and the sum range the same height, starting on the same row.

A number written as a comparison without quotes

Greater than 10 has to be the text ">10". The quotes belong around the operator and the number together.

Expecting SUMIF to apply two conditions

A second criterion is not an optional extra on SUMIF. SUMIFS exists because the argument list had to put the sum range first so more pairs could follow.

Versions and compatibility

SUM and SUMIF are in every Excel version still in normal use, and in Google Sheets. Wildcards * and ? work in both.

SUMIFS is in Excel 2007 and later and in Google Sheets. A file that truly must open in Excel 2003 would use SUMPRODUCT for several conditions. That case is rare now. The SUMPRODUCT page shows the pattern.

Comma separators in the examples match a United States locale. Semicolon locales change the punctuation, not the order of the arguments.

Practice on Formula Drills

Free drills are open with no account. Premium drills show the problem to everyone and grade the sheet for subscribers.

Free exercises

Premium exercises

Function pages

FAQ

Does SUMIF care about capital letters?

No. "East" matches east and EAST. An exact product code that differs only by case is still a match.

Can the criterion live in a cell?

Yes. SUMIF(A2:A5, E2, C2:C5) uses whatever text or number is in E2. Comparisons in a cell still include the operator, so the cell contains >10 rather than the formula trying to add quotes of its own.

What does SUMIF return when nothing matches?

0. That is different from AVERAGEIF, which returns #DIV/0! when no cell qualifies. A zero from SUMIF can mean a real zero or a criterion that never hit. Check the spelling of the criterion before you trust it.

How do I add East or West?

SUMIF for East plus SUMIF for West. SUMIF itself is an AND of one test only. SUMIFS does not turn into OR by adding another pair. Another pair makes the test stricter.