Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Everyone,
Can anyone please provide me help in the 'for each loop' implementation. Here I'm attaching a qvw file.
Requirement is as below
as in below Image I want to put qty 5 through 'for each loop', on marked place, means when according to one itemid the location is change then qty should be 5.
I'm not able to implement for each loop in this please anyone provide some idea.
Thanks
Temp:
LOAD * INLINE [
ItemID, LocationID, Date, Qty
I1, L1, 01-05-14, 5
I1, L1, 02-05-14,
I1, L1, 03-05-14,
I1, L2, 04-05-14,
I1, L2, 05-05-14,
I2, L2, 06-05-14,
I2, L3, 07-05-14,
I3, L3, 08-05-14,
I3, L3, 09-05-14,
I3, L4, 10-05-14,
I3, L1, 11-05-14,
I4, L4, 12-05-14,
I4, L3, 13-05-14,
I4, L4, 14-05-14,
I4, L5, 15-05-14,
I5, L2, 16-05-14,
I5, L5, 17-05-14,
I5, L5, 18-05-14,
I5, L1, 19-05-14,
];
NoConcatenate
tmp:
Load ItemID, LocationID, Date, If( ItemID & LocationID <> Previous(ItemID) & Previous(LocationID),FieldValue('Qty',1)) As Qty
Resident Temp
ORDER BY ItemID, LocationID;
DROP Table Temp;
Hi,
Try this script
Temp:
LOAD * INLINE [
ItemID, LocationID, Date, Qty
I1, L1, 01-05-14, 5
I1, L1, 02-05-14,
I1, L1, 03-05-14,
I1, L2, 04-05-14,
I1, L2, 05-05-14,
I2, L2, 06-05-14,
I2, L3, 07-05-14,
I3, L3, 08-05-14,
I3, L3, 09-05-14,
I3, L4, 10-05-14,
I3, L1, 11-05-14,
I4, L4, 12-05-14,
I4, L3, 13-05-14,
I4, L4, 14-05-14,
I4, L5, 15-05-14,
I5, L2, 16-05-14,
I5, L5, 17-05-14,
I5, L5, 18-05-14,
I5, L1, 19-05-14,
];
Data:
LOAD
*,
If(Previous(ItemID) <> ItemID OR LocationID <> Previous(LocationID),5) AS NewQty;
LOAD
*
RESIDENT Temp
ORDER BY ItemID, LocationID;
DROP TABLE Temp;
Regards,
Jagan.
Hi anbu,
Thanks for the reply . This logic is working but I want to implement for each loop in the script.
Hi Manoj,
For loop will have performance issues, if you are able to do it without loop then try without using loops. Using loops is not suggestible.
Regards,
Jagan.
Hi jagan,
Thank you so much for the reply and suggestions. This logic is working fine .
Actually I am learning that how to use for each loop in qlikview script.
Thanks
Hi Manoj,
Check this links
Loop through Folders and sub folders to get file names
Hope this links helps you.
Regards,
Jagan.