I've got quarterly demand and supply. I need to know how many quarters it will take for the supply to meet each demand
C2 is initial demand (followed by quarterly demand for next in C6) and E2 is initial supply (followed by quarterly supply)
It takes five quarters for the cumulative supply, SUM(E2:E6), to meet the demand,C2
There is leftover demand, SUM(E2:E6-C2), 323,487-276,459=47,028 that needs to be accounted against quarters supply and directly impacts the quarterly drawdown time dynamically column G.
The issue arises when column D becomes negative.
The negative value in represents additional supply that needs to be accounted for in E20 and so forth down column E, a surplus supply gets added to the next quarter's supply.
I used =IFERROR(MATCH(D6,SUBTOTAL(9,OFFSET(OFFSET($E$2,SUM($F$2:F5),0),,,ROW(E6:$E$633)-ROW(E6))),1),1) to calculate the drawdown time required in column F and adjusted each each drawdown time for the previous quarter's required drawdown time, column G.
For reference, I color coded how the above formula works.
C2 is initial demand (followed by quarterly demand for next in C6) and E2 is initial supply (followed by quarterly supply)
It takes five quarters for the cumulative supply, SUM(E2:E6), to meet the demand,C2
There is leftover demand, SUM(E2:E6-C2), 323,487-276,459=47,028 that needs to be accounted against quarters supply and directly impacts the quarterly drawdown time dynamically column G.
The issue arises when column D becomes negative.
The negative value in represents additional supply that needs to be accounted for in E20 and so forth down column E, a surplus supply gets added to the next quarter's supply.
I used =IFERROR(MATCH(D6,SUBTOTAL(9,OFFSET(OFFSET($E$2,SUM($F$2:F5),0),,,ROW(E6:$E$633)-ROW(E6))),1),1) to calculate the drawdown time required in column F and adjusted each each drawdown time for the previous quarter's required drawdown time, column G.
For reference, I color coded how the above formula works.