# How to calculate a running total by group in Excel

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.

**Excel:** `=SUMIFS($C$2:C2,$B$2:B2,B2)` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D |
| --- | --- | --- | --- |
| Date | Category | Amount | Running total |
| 2026-03-02 | Travel | 420 |  |
| 2026-03-03 | Meals | 65 |  |
| 2026-03-05 | Travel | 310 |  |
| 2026-03-09 | Supplies | 140 |  |
| 2026-03-10 | Meals | 48 |  |
| 2026-03-12 | Travel | 575 |  |
| 2026-03-16 | Supplies | 92 |  |
| 2026-03-18 | Meals | 112 |  |

Formula in D2, filled to D9: `=SUMIFS($C$2:C2,$B$2:B2,B2)`

Result: $420; $65; $730; $140; $113; $1,305; $232; $225

## 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.

## Other ways

- `=SUMIF($B$2:B2,B2,$C$2:C2)`: 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.

## 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…

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/running-total-by-group
