I have a data set look like
<tbody>
</tbody>
each Road_ID has several rows. V1cum, V2cum and V3cum are cumulative sum of V1, V2 and V3 respectively which starts from zero after finishing each Road_ID. I need to restart cumulative sum after reaching 5 in V1cum and after finishing a Road_ID.
My expected result is
<tbody>
</tbody>Please help me reaching this result.
Thanks,
Sadia
Road_ID | V1 | V1cum | V2 | V2cum | V3 | V3cum |
1 | 2 | 2 | 0 | 0 | 1 | 1 |
1 | 4 | 6 | 3 | 3 | 1 | 2 |
1 | 3 | 9 | 4 | 7 | 4 | 6 |
1 | 3 | 12 | 2 | 9 | 1 | 7 |
2 | 0 | 0 | 4 | 4 | 2 | 2 |
2 | 3 | 3 | 3 | 7 | 2 | 4 |
2 | 4 | 7 | 1 | 8 | 3 | 7 |
2 | 1 | 8 | 3 | 11 | 1 | 8 |
2 | 0 | 8 | 2 | 13 | 4 | 12 |
2 | 2 | 10 | 1 | 14 | 0 | 12 |
<tbody>
</tbody>
each Road_ID has several rows. V1cum, V2cum and V3cum are cumulative sum of V1, V2 and V3 respectively which starts from zero after finishing each Road_ID. I need to restart cumulative sum after reaching 5 in V1cum and after finishing a Road_ID.
My expected result is
Road_ID | V1 | V1cum | V2 | V2cum | V3 | V3cum |
1 | 2 | 2 | 0 | 0 | 1 | 1 |
1 | 4 | 6 | 3 | 3 | 1 | 2 |
1 | 3 | 3 | 4 | 7 | 4 | 6 |
1 | 3 | 6 | 2 | 2 | 1 | 1 |
2 | 0 | 0 | 4 | 4 | 2 | 2 |
2 | 3 | 3 | 3 | 7 | 2 | 4 |
2 | 4 | 7 | 1 | 1 | 3 | 7 |
2 | 1 | 1 | 3 | 4 | 1 | 1 |
2 | 0 | 1 | 2 | 6 | 4 | 5 |
2 | 2 | 3 | 1 | 7 | 0 | 5 |
<tbody>
</tbody>
Thanks,
Sadia