Skip to content

Total by one condition with SUMIF

Math that comes up at work8 min

Builds on Add it up with SUM and Copy a formula down a column.

Every Monday, a sales manager in Ontario reports last week's orders region by region. The orders arrive as one list with the regions mixed together, so a plain SUM can't split them.

How it works

SUMIF adds up the numbers on the rows that pass one test. Picture going down the region column with a highlighter and marking every row that says North. SUMIF then adds the amounts on the marked rows and skips the rest. It pairs the two columns row by row, so they must start and end on the same rows.

RowABC
1ArgumentWhat it isExample
2rangethe cells to testD2:D12
3criteriathe test"Warehouse"
4sum_rangethe cells to add, on the same rows (optional)F2:F12

Text to match goes in quotation marks, and capitals don't matter. A comparison goes in quotation marks too, like ">500". A cell such as H1 matches whatever is in it, and to compare with a cell, join the comparison to it with &: ">"&H1. Leave out sum_range and SUMIF adds the cells it tests.

Example

A staff list has departments in D2:D12 and each person's overtime hours this month in F2:F12.

=SUMIF(D2:D12,"Warehouse",F2:F12)
Adds the overtime hours in F2:F12 on the rows where the department in D2:D12 is Warehouse.

With three warehouse staff on 6, 11.5 and 4 hours, it returns 21.5. A department typed as warehouse, in small letters, still counts.

Common mistakes

  • =SUMIF(F2:F12,"Warehouse",D2:D12) swaps the ranges and returns 0, because it looks for Warehouse among the hours. The range you test comes first and the numbers to add come last.
  • =SUMIF(F2:F12,">H1") returns 0: inside quotation marks, H1 is just text. Join the comparison to the cell: ">"&H1.
  • ">500" leaves out an amount of exactly 500. "That much or more" is ">=500".
  • =SUMIF(D3:D12,"Warehouse",F3:F12) leaves out the first row, with no error. Start both ranges on the first row of data.

In short

  • =SUMIF(range, criteria, sum_range) tests one column and adds another on the same rows.
  • Text and comparisons go in quotation marks; capitals don't matter.
  • Take the test from a cell to change it without editing the formula, and join a comparison to the cell with &.
  • Lock the ranges with $ before you fill a SUMIF down a summary.

Practice

4 exercises · free with an account

Start practicing
  1. Not started

    1. Sales for the North region

    Formula · easy

  2. Not started

    2. Claims for the chosen cost center

    Formula · medium

  3. Not started

    3. Invoices that need approval

    Formula · medium

  4. Not started

    4. Sales for every product line

    Formula · hard