Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, I am new to qlik,
I have some qvd partitioned in months, with the format:
Sales_202310.qvd
Sales_202309.qvd
Sales_202308.qvd
Sales_202307.qvd
Sales_202306.qvd
... Sales_202301.qvd
i want to load in my qlik, only the last 5 months (oct - jun).
this is code i have, that loads only the current month, how can i load in addition to the current month 4 more months? :
Let lastmonth = Date(today(),'YYYYYYMM');
TmpData:
LOAD
LAST_DATE_LOAD,
SALES
FROM QVDS\SALES_$(lastmonth).QVD(qvd)
;
Apologies my bad, the code goes to 5 months in future where as we have to go in history,
Please change below code.
For i=0 to 4
Let lastmonth = Date(Addmonths(today(),-$(i)),'YYYYMM');
TmpData:
LOAD
LAST_DATE_LOAD,
SALES
FROM QVDS\SALES_$(lastmonth).QVD(qvd)
;
Next
Hi,
You can run through a loop like below
For i=0 to 4 //Because it includes 0 as well
Let lastmonth = Date(Addmonths(today(),$(i)),'YYYYMM');
TmpData:
LOAD
LAST_DATE_LOAD,
SALES
FROM QVDS\SALES_$(lastmonth).QVD(qvd)
;
Next
Hello Kaushik,
thanks for your quick reply!
I'm getting an error, try to search for the november qvd (202311) ...
In such case change your for statement from
For i=0 to 4
To
For i=1 to 5
hi Kaushik
I have changed the loop to For i=1 to 5 and the process is still trying to find the qvd Sales_202311.qvd ...
Please share your script.
code:
For i=1 to 5
Let lastmonth = Date(Addmonths(today(),$(i)),'YYYYMM');
TmpData:
LOAD
LAST_DATE_LOAD,
SALES
FROM QVDS\SALES_$(lastmonth).QVD(qvd)
;
Next
script error:
Unable to open the file 'QVDS\SALES_202311.QVD' The system cannot find the specified file.
TmpData:
LOAD
LAST_LOAD_DATE,
SALES
FROM QVDS\SALES_202311.QVD(qvd)
Apologies my bad, the code goes to 5 months in future where as we have to go in history,
Please change below code.
For i=0 to 4
Let lastmonth = Date(Addmonths(today(),-$(i)),'YYYYMM');
TmpData:
LOAD
LAST_DATE_LOAD,
SALES
FROM QVDS\SALES_$(lastmonth).QVD(qvd)
;
Next
Thank you so much Kaushik!
That was it!