Instant digital downloadExcel and Google SheetsSecure card checkout

Excel and Google Sheets how-to

Total each category with SUMIFS

Add up all the Fuel, all the Office, all the Meals: one formula per category, and more rules when you need them.

ABCDE
1CategoryAmountCategoryTotal
2Fuel60.00Fuel135.00
3Office25.50Office37.50
4Fuel45.00Meals18.75
5Meals18.75
6Office12.00
7Fuel30.00

Sample data. Expenses in A:B, the formula in E2 is copied down for each category.

The formula

List your categories in a column (D here), click the first Total cell and type:

=SUMIFS(B:B,A:A,D2)

E2 shows 135: 60 + 45 + 30, every Fuel row. Copy it down and Office shows 37.50 and Meals 18.75.

  • B:B is the column to add up, the amounts.
  • A:A is the column to check.
  • D2 is what to match, the category.

Quick check: the three totals add up to 191.25, the same as =SUM(B2:B7). If your category totals come up short, a row has a category that is spelled differently.

Add more rules

Each extra rule is a pair: a column, then its condition. A row is added only when every rule is true.

=SUMIFS(B:B,A:A,"Fuel",B:B,">50")

Only the Fuel rows over 50 count, so the result is 60. Conditions with an operator go in double quotes.

Take the limit from a cell

Put the number in a cell (H1 = 50) and join it to the operator with &:

=SUMIFS(B:B,A:A,D2,B:B,">"&H1)

Same result, 60, and you change the limit without touching the formula.

Between two amounts

Use the same column twice, once for each end:

=SUMIFS(B:B,B:B,">=20",B:B,"<=50")

That adds 25.50, 45 and 30: 100.5.

Everything except one category

"<>" means "not equal to":

=SUMIFS(B:B,A:A,"<>Fuel")

Office and Meals together: 56.25.

SUMIF or SUMIFS?

SUMIF takes one condition and puts the column to add last:

=SUMIF(A:A,D2,B:B)

It gives the same 135. SUMIFS puts the column to add first and takes as many conditions as you need, so it is the one to learn. Both work in every Excel since 2007 and in Google Sheets.

Free practice sheet

Try it on three small jobs: sales by region with SUMIF, expenses with two rules and a limit taken from a cell (">="&H4, not ">=H4"), and counting rows with COUNTIF and COUNTIFS. Each tab has yellow cells to fill in and a Check column that says Correct or Try again as you type, plus an Answers tab. One Excel file that opens in Google Sheets too. Free, no sign up. Sample data.

Download the practice sheet (.xlsx, 11 KB)

Watch it in 35 seconds

Templates with the math already done

Rather skip the formulas? These templates come with every formula built and checked, plus a filled-in sample.

Teaching this to a class or team?

Get one tip like this a month

A free email from VARS Digital with one Excel or Google Sheets fix, tested in both apps. No spam, unsubscribe any time.

By signing up you agree that VARS Digital, 10151 240 Street, Maple Ridge, BC V2W 0G9, Canada (inquiries@varsdigital.app) may email you its newsletter: Excel and Google Sheets tips, updates and news about our templates and lessons. We send a confirmation email first, and nothing else goes out until you click it. Every email has an unsubscribe link, and you can leave any time. Details in our store policies.

More how-tos