Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Experts
I am Having Last 3 Years data(2013,2014,2015)
QVD names are as following,
Sales_201201.qvd
sales_201202.qvd
.
.
sales_201506.qvd
sales_201507.qvd
sales_201508.qvd
sales_201509.qvd
sales_201510.qvd
sales_201511.qvd
sales_201512.qvd
From the above data set, i want to load last 6 months QVD's only .....
How we can load the last 6 Months qvd's ?
Note : If Sales_201601.qvd, exist then load (sales_201507,201508,201509,201510,201511,201512,201601)
Please Help to me Write the Script...
Best Regards,
Madhu
Please see the attachment.. it might be helpful for you..
If you need dynamic solution you can follow the below approach
let vQVDPath ='D:\Qlik\QVD; // Define your QVD folder path
for Each vFile in FileList('$(vQVDPath)\*.qvd')
FileName:
LOAD subfield(subfield(SubField('$(vFile)','\',-1),'.',1),'_',2) as FileName
AutoGenerate(1);
NEXT vFile
MaxMonth:
LOAD MaxMonth - IterNo()+1 as Last_6_Months
While IterNo() <=7;
LOAD max(FileName) as MaxMonth
Resident FileName;
DROP Table FileName;
Final:
LOAD * Inline [
junk ];
for i=1 to FieldValueCount('Last_6_Months')
let vMonth = FieldValue('Last_6_Months',$(i));
Concatenate(Final)
LOAD *,
FileBaseName() as FileName
FROM
[$(vQVDPath)\Sales_$(vMonth).qvd]
(qvd);
NEXT i
DROP Field junk;
DROP Table MaxMonth;