My data is as follows:
Factory ID | Week | CAPACITY | Request |
---|---|---|---|
1 | 21 | 1000 | 500 |
1 | 22 | 1000 | 1200 |
1 | 23 | 1500 | 1600 |
1 | 24 | 1500 | 1100 |
2 | 21 | 1000 | 500 |
2 | 22 | 2000 | 1900 |
2 | 23 | 2000 | 1000 |
2 | 24 | 2000 | 2500 |
3 | 21 | 1000 | 200 |
3 | 22 | 1000 | 900 |
3 | 23 | 1000 | 1300 |
3 | 24 | 1000 | 800 |
I want to calculate backlog in a measure or any other way to have backlog be dynamic based on the factories I select. Backlog is calculated as follows:
Backlog = Capacity - (Request + Previous week backlog); where we have backlog when requests + pre. week backlog exceeds capacity or else it is 0. I cannot move capacity from future weeks, so the backlog would always accumulate going forward
Eg. If I select Factory 1, my backlog should look as follows:
Factory Selected: 1
Week | Backlog |
---|---|
21 | 0 |
22 | -200 |
23 | -300 |
24 | -100 |
Factory Selected: 1,2
Week | Backlog |
---|---|
21 | 0 |
22 | -100 |
23 | 0 |
24 | -400 |
Factory Selected: 1,3
Week | Backlog |
---|---|
21 | 0 |
22 | -100 |
23 | -500 |
24 | 0 |
I have been trying to find a solution since the last 2 days. Let me know if you need any additional details. Any help will be greatly appreciated.