excelgroup-bysumcumulative-sum

Excel - How do I create a cumulative sum column within a group?


In Excel, I have an hours log that looks like this:

PersonID   Hours   JobCode
1          7       1
1          6       2
1          8       3
1          10      1
2          5       3
2          3       5
2          12      2
2          4       1

What I would like to do is create a column with a running total, but only within each PersonID so I want to create this:

PersonID   Hours   JobCode    Total
1          7       1          7 
1          6       2          13
1          8       3          21
1          10      1          31
2          5       3          5
2          3       5          8
2          12      2          20
2          4       1          24

Any ideas on how to do that?


Solution

  • In D2 and fill down:

    =SUMIF(A$2:A2,A2,B$2:B2)