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

Scripting Issue


I have generated yearly QVDs based on the year field present in the file.

Now, i have to store the QVDs prior to 2013 into an archive folder and the QVDs after 2013 in the current folder.

I have used the below code for generating yearly QVDs

temp:

load min(Year) as MinY,

max(Year) as MaxY

resident tab;

let MI= peek('MinY', 0 , 'temp');

let MA= peek('MaxY' , 0, 'temp');

for i= $(MI) to $(MA)

tabtemp:

noconcatenate

load * resident tab where Year=$(i);

store * from tabtemp into ../../Abc_$(i).qvd(qvd)

drop table tabtemp;

How do i modify the above code so that it stores the QVDs prior to 2013 in Archvie folder and the QVDs genertaed after 2013 in another folder.

1 Solution

Accepted Solutions
marcus_malinow
Partner - Specialist III
Partner - Specialist III

also add

drop table tabtemp;

after the endif

View solution in original post

10 Replies
marcus_malinow
Partner - Specialist III
Partner - Specialist III

if $(I) <2013 then

    store tabtemp into ..\archive\Abc_$(i).qvd (qvd);

else

    store tabltemp into ..\othefolder\Abc_$(I).qvd (qvd);

endif

Not applicable
Author


Hi Marcus,

When i am using if else in the below code,

for i =$(MI) to $(MA)

tabtemp:

noconcatenate

load * resident tab where Year=$(i);

if $(i) >=year(today()) -1 then

store * from tabtemp into ../.. ABC_$(i).qvd(qvd);

else

store * from tabtemp into ../../ABC_$(i).qvd(qvd);

endif

next

In the above case the qvds are getting stored into different folders, but all the QVDs contain the data only for 2012 i.e. the minimum year.

When if else statement is removed it works fine.

marcus_malinow
Partner - Specialist III
Partner - Specialist III

ok, in the code above you have a syntax issue on your first store statement

store * from tabtemp into ../.. ABC_$(I).qvd (qvd);

marcus_malinow
Partner - Specialist III
Partner - Specialist III

I'd also maybe add a trace statement inside the loop.

Trace $(i);

Just to make sure your MI and MA variables are being set correctly.

Not applicable
Author

But when the if else part is removed from the code, it works perfectly fine...

perumal_41
Partner - Specialist II
Partner - Specialist II

GHi

Try below

for i =$(MI) to $(MA)

tabtemp$(i):

noconcatenate

load * resident tab where Year=$(i);

if $(i) >=year(today()) -1 then

store * from tabtemp$(i) into ../.. ABC_$(i).qvd(qvd);

else

store * from tabtemp$(i) into ../../ABC_$(i).qvd(qvd);

endif

next

marcus_malinow
Partner - Specialist III
Partner - Specialist III

ok possibly an issue on your if condition

Try

if $(i) >= (Year(Today()) - 1) then

marcus_malinow
Partner - Specialist III
Partner - Specialist III

also add

drop table tabtemp;

after the endif

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Is this now working?

If so, please mark as answered.