Accumulated values (months before) for reduction of current month
I have a problem with accumulation and reduction. It's hard to explain, but I've done my best in the table below. The dimensions used are Client and Closure Date. The values I get from the load script are Consumption and Produced, the rest needs to be calculated somehow.. The most important columns are the 2 last, the other are just there for explaining the problem..
Client
Consumption closure date
Consumption
Possible reduction (80% of Consumpt.)
Produced (for reduction)
Reduction this month
Left after reduction this month
Actual reduction incl. Acc.
Acc. Reduction left for use
68
583244
2010-10-01
814
651
541
541
0
541
68
583244
2010-09-01
839
671
597
597
0
671
178
583244
2010-08-01
797
638
676
638
38
638
252
583244
2010-07-01
752
602
815
602
213
602
213
583244
2010-06-01
743
594
511
511
0
511
0
Please help me figure this out before I throw my pc out the window! 🙂
To clerify.. The produced should be taken from the comsumption, but not more then 80% (the rest will be added to balance for use the next month and so on..). If production doesn't fill the 80% of consumption, then the balance will not be affected at all, however if there is a saved balance it will be added to production to fill up as much as possible of the 80%.