How to calculate a running total by group in Excel
Formula (Excel and Google Sheets)
=SUMIFS($C$2:C2,$B$2:B2,B2)Use SUMIFS on ranges that grow as you fill down: =SUMIFS($C$2:C2,$B$2:B2,B2) adds only the earlier rows of the same group.
- Result on the example
- one result per row in
D2, filled down toD9 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in D2, filled down to D9. Change any input and the result updates, or edit the formula to experiment.
How it works
Both ranges start at a locked row 2 and end at the current row, so in row 6 the formula reads $C$2:C6 and $B$2:B6. SUMIFS adds the amounts in that block whose category equals this row's category. Each category keeps its own total even though the rows are mixed together.
=SUMIFS($C$2:C2,$B$2:B2,B2)Result420
$C$2:C2$420A range: one cell.
$B$2:B2"Travel"A range: one cell.
B2"Travel"The value in B2.
SUMIFS($C$2:C2,$B$2:B2,B2)420SUMIFS: Adds values that meet every condition.- sum_range
$C$2:C2$420 - criteria_range1
$B$2:B2"Travel" - criteria1
B2"Travel"
- sum_range
In Google Sheets
The same formula works in Google Sheets: =SUMIFS($C$2:C2,$B$2:B2,B2). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =SUMIF($B$2:B2,B2,$C$2:C2) | $420, $65, $730… | The same with SUMIF, which takes the range to add last. |
Common mistakes
- Locking both ends (
$C$2:$C$9) gives every row the category's final total instead of a running one. - Sorting the data after filling changes which rows count as "earlier". Sort first, then fill the formula.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Calculate a running total by group
D2, write a running total that restarts for each category, then fill down to D9.Questions
How do I reset the running total each month?
Add the month as a condition: =SUMIFS($C$2:C2,$A$2:A2,">="&EOMONTH(A2,-1)+1) restarts on the first of every month.
How do I do a running count by group?
Use =COUNTIF($B$2:B2,B2), which numbers each category's rows 1, 2, 3…
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.