What I did is fill the future with the last non zero value using Above then accumulate the demand and then subtract these two values. The problem is that I cannot plot this and also I need to have two dimensions on chart Date and Part.
My final goal would be something like this but for all parts on one graph:
Thank You for Your response. I tried to use this script but it doesn't work as I was hoping for. I will try to explain my task in little more detail. Quantity on stock is a known quantity on our warehouse from past until today. Demand means how many parts we will need on particular date. Therefore my task is to plot quantity on stock up until today like here:
and then assume that on the next date (7/28/2019) I will have Quantity on stock (7/24/2019) - Demand(7/28/2019). After, on the date (7/30/2019) = Previous Calculated quantity on (7/28/2019) - Demand (7/30/2019) or the date (7/30/2019) = Quantity on (7/24/2019) - Demand(7/28/2019) - Demand (7/30/2019) etc.
So the result for part A would be:
7/28/2019,A,25 - 5[Demand on (7/28/2019)] = 20
7/30/2019,A,20 - 5[Demand on 7/30/2019] = 15
OR Also possible:
7/30/2019,A,25 - 5[Demand on 7/28/2019] - 5[Demand on 7/30/2019] = 15