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

Using Loop for multiple Load statement

Hello,

Kindly help me in solving the below issue.

Test:

Plant     Material     Tot_Qty

ABC     1001          500

XYZ     1002          1000

Order

OrderNo    Plant     Material     Date           Qty_2

1               ABC        1001      1/1/2013        100

2               ABC        1001      2/10/2013      200

3               ABC        1001     15/12/2013     200

From the above data, I need to check that for Particular Plant and Material, how many orders are placed as per order date.

For Eg,

OrderNo : 1, Qty_2 : 100.

Subtract Qty_2 from Tot_Qty and loop it till the Tot_Qty becomes 0.

Thanks

Sumeet

9 Replies
Nagaraju_KCS
Specialist III
Specialist III

Hi Community,

I have same problem like this

please give me anyone solution ASAP,

---Raju

jagan
Partner - Champion III
Partner - Champion III

Hi,

Can you clarify what should be your final output with example.

Regards,

Jagan.

vikasmahajan

I think you should try RangeSum(Above(Sum(Qty), 0, RowNo()))

Please find  attachment of demo which can help you.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Nagaraju_KCS
Specialist III
Specialist III

Hi Jagan,

Output would be

Test:

Plant     Material     Tot_Qty

ABC     1001          500

XYZ     1002          1000

Order

OrderNo    Plant     Material     Date           Qty_2

1               ABC        1001      1/1/2013        100

2               ABC        1001      2/10/2013      200

3               ABC        1001     15/12/2013     200

O/P:

Row1:

OrderNo    Plant     Material     Date           Qty(Tot_Qty-Qty_2)

1               ABC        1001      1/1/2013         400


Suppose Tot_Qty=500

                 Qty_2=100

(Tot_Qty-Qty_2)= 500-100

Now, 400 would be Tot_Qty for next OrderNo

400-200


---Raj

jagan
Partner - Champion III
Partner - Champion III

Hi,

Please try this script

Temp:

LOAD * Inline [

Plant,     Material,     Tot_Qty

ABC,     1001,          500

XYZ,     1002,          1000];

Left Join

LOAD *

Inline [

OrderNo,    Plant,     Material,     Date,           Qty_2

1,               ABC,        1001,      1/1/2013,        100

2,               ABC,        1001,      2/10/2013,      200

3,               ABC,        1001,     15/12/2013,     200

];

Data:

LOAD

*,

If(Previous(Plant) = Plant and Previous(Material) = Material , Peek('TempTotal') - Qty_2, Tot_Qty - Qty_2)  AS TempTotal

RESIDENT Temp

ORDER BY Plant, Material, OrderNo;

DROP TABLE Temp;

Regards,

Jagan.

Nagaraju_KCS
Specialist III
Specialist III

Hi Jagan,

The above Solution is not working for some values.

PFB snapshot of the data.

Order DateMaterial NoPlantATP QtyOrderedCumulative QtyStatus
2/11/201328112A0165505010054950OK
22-11-201328112A0165505010054850OK
26-11-201328112A0165505010054750OK
26-11-201328112A0165505020054550OK

Order DateMaterial NoPlantATP QtyOrderedCumulative QtyStatus
2/11/201328112A0161008020OK
22-11-201328112A01610050-30Invalid

The solution provided by you is giving the attached output.

maxgro
MVP
MVP

Hi

please see attachment, result in image

Regards

103352 2.jpg

jagan
Partner - Champion III
Partner - Champion III

Hi,

Can you attach the file and data which you are working, I think your script has issue.  Did you ordered the resultset

ORDER BY Plant, Material, OrderNo

Regards,

Jagan.

Not applicable
Author

Hi Massimo/Jagan,

The Result set for the data should be :

Order Date
Material NoPlantATP  QtyOrderedCumulativeQtyStatus
2/11/201328112A0165505010054950OK
22-11-201328112A0165505010054850OK
26-11-201328112A0165505010054750OK
26-11-201328112A0165505020054550OK
 
 
 

For 1st Row, ATP Qty - Ordered (55050-100 = 54950)

For 2ns Row, ATP Qty  should be the result of 1st Row. ie. (54950-100 = 54850) and so on.

Kinldy help as how to get these type of result in a loop. Also the moment we get any negative result set, loop should be terminated with the apprpriate status.

Regards

Sumeet