FormulaCraft

How to sum by category in Excel and Google Sheets

Topic:SUM & aggregation
Excel & Google Sheets
=SUMIF(A2:A6,"Fruit",B2:B6)

Verified example

Computed by a real spreadsheet engine on the sample data below.

CategorySales
Fruit300
Vegetable150
Fruit200
Dairy400
Vegetable120

=SUMIF(A2:A6,"Fruit",B2:B6)500

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Ensure your data has a category column (e.g. A) and a numeric column (e.g. B).
  2. 2In an empty cell type =SUMIF(A2:A6,"Fruit",B2:B6) replacing "Fruit" with the category you want and adjusting ranges to fit your data.
  3. 3Press Enter. The formula returns the sum of all rows in column B where column A equals "Fruit".

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

What if I need to match two criteria, e.g. category AND month?

Use SUMIFS instead: =SUMIFS(C2:C6,A2:A6,"Fruit",B2:B6,"Jan").

Can I use wildcards in the criteria?

Yes. =SUMIF(A2:A6,"Fr*",B2:B6) will match any category starting with "Fr".

More on SUM & aggregation

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: