FormulaCraft

How to create a running total by group in Excel and Google Sheets

Topic:SUM & aggregation
Excel & Google Sheets
=SUMIFS(B$2:B2,A$2:A2,A2)

Verified example

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

GroupValue
East100
East200
East150
West300
West250
West100

=SUMIFS(B$2:B2,A$2:A2,A2)100

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. 1Sort your data so rows with the same group label are contiguous: column A = Group, column B = Value.
  2. 2In C2 enter =SUMIFS(B$2:B2,A$2:A2,A2). The dollar sign on the row number of the start ($2) anchors the range top; the unfixed end row expands as you copy down.
  3. 3The criteria A2 matches only rows with the same group label up to the current row.
  4. 4Copy C2 down through C7 — each row accumulates only its own group's values from the top of the range to that row.
  5. 5When the group label changes (e.g., from 'East' to 'West'), the SUMIFS criteria no longer match previous rows, effectively resetting the running total.

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

Why does the running total not reset when the group changes?

Check that the group column values are truly identical (no trailing spaces). Use TRIM(A2) or exact match to verify. Also confirm data is sorted by group.

Can I create a running total without sorting my data?

Yes — use =SUMPRODUCT((A$2:A2=A2)*B$2:B2). This evaluates all preceding rows regardless of order but is slower on large datasets.

How do I restart the running total at the start of each month within a group?

Add a third SUMIFS criterion on a date column: =SUMIFS(B$2:B2,A$2:A2,A2,MONTH(C$2:C2),MONTH(C2)) where C holds dates.

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: