This is the data frame
Date ID cost Value
15/12/2016 1 yes 200
15/10/2016 1 yes 100
15/9/2016 1 yes 55
15/04/2016 1 yes 1000
15/12/2016 2 yes 300
15/10/2016 2 yes 200
15/9/2016 2 yes 100
15/04/2016 2 yes 1000
15/12/2016 3 no 300
15/10/2016 3 no 200
15/9/2016 3 no 100
15/04/2016 3 no 1000
I'd like to repeat the rolling sum on 3 month for each ID that have a cost = "yes". Note that in the example the IDs are just 3 but in my DB are n.
The output should be
Date ID Value Rolling_Sum
15/12/2016 1 200 355
15/10/2016 1 100 155
15/9/2016 1 55 55
15/04/2016 1 1000 1000
15/12/2016 2 300 600
15/10/2016 2 200 300
15/9/2016 2 100 100
15/04/2016 2 1000 1000
I've seen a lot of example in other questions. one of my biggest problem is that the date is not continue.. so i can have different lag between different data.
Thanks