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

Working on a sheet you inherited? Run the Auditor on the whole file first — it flags every #REF!, #N/A, broken column pattern, and inconsistent formula in seconds, free, no signup.

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

Related tasks

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

Last reviewed: