Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

return the previous month amount in current month

Hi,

I want to be able to create a rolling stock on hand report based on a stock on hand report updated each day, adding units in transit to our warehouse from our head office overseas (based on the expected receipt date) minus forecast orders going to customers to create a SOH at month end. I then want to include future months where the following months Open SOH (stock on hand) equals the previous months Closing SOH.

I can assign the current month Open SOH using a today() function in the stock on hand load but I cannot seem to get next months (Nov-14) Open SOH to be Oct-14 Closing SOH. E.g. for Product1 we will end Oct-14 with 428 units in the warehouse. I then want Nov-14 Open SOH to be 428 so when we take off the forecast customer orders of 160 units in November the Closing SOH says 268 units not 112.

I have tried a number of ways to do this without any luck. I included a dimension called PeriodChrono as each month is given an accending number and the report knows that 76 is the current month if that helps.

Can anyone suggest any solutions?

PeriodNameOct-14Oct-14Oct-14Oct-14Nov-14Nov-14Nov-14Nov-14
PeriodChrono7676767677777777
SKUOpen SOHUnits in TransitForecast OrdersClosing SOHOpen SOHUnits in TransitForecast OrdersClosing SOH
Product127257642042800160112
Product25861,0821,06060800400186
Product355268866857200260292
Product43,81906,758-2,939002,2001,619
Product51,430001,4300001,430
Product686801,719-85100520348
Product79576161881,38500957
Product849558056850700220275
Product970499295274400368336
Product101,03041201,442----

Thanks

David

1 Reply
anbu1984
Master III
Master III

You can try like this in script

Temp:

Load *,Match(SKU,'Open SOH','Units in Transit','Forecast Orders','Closing SOH') As Ord Inline [

PeriodName,PeriodChrono,SKU,Product,Amount

Oct-14,76,Open SOH,Product1,272

Oct-14,76,Units in Transit,Product1,576

Oct-14,76,Forecast Orders,Product1,420

Oct-14,76,Closing SOH,Product1,428

Nov-14,77,Open SOH,Product1,0

Nov-14,77,Units in Transit,Product1,0

Nov-14,77,Forecast Orders,Product1,160

Nov-14,77,Closing SOH,Product1,112

Oct-14,76,Open SOH,Product2,586

Oct-14,76,Units in Transit,Product2,1082

Oct-14,76,Forecast Orders,Product2,1060

Oct-14,76,Closing SOH,Product2,608

Nov-14,77,Open SOH,Product2,0

Nov-14,77,Units in Transit,Product2,0

Nov-14,77,Forecast Orders,Product2,400

Nov-14,77,Closing SOH,Product2,186 ];

NoConcatenate

Final:

Load PeriodName,PeriodChrono,SKU,Product,If(Product=Previous(Product) And PeriodChrono = Previous(PeriodChrono)+1 And SKU='Open SOH' And Amount = 0, Previous(Amount),Amount) As Amount

Resident Temp Order by Product,PeriodChrono,Ord;

Drop Table Temp;