Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using If Else in Script

I am loading all the QVDs present in a folder. The QVDs have year suffixed to it's name. e.g. Sample_2012.qvd, Sample_2013.qvd and so on...

I have to store latest two years qvds in one folder and the QVDs prior to 2 years in another folder. How do i do that?

1 Reply
Anonymous
Not applicable
Author

Hi Asma

Below is the code which will work for you

Temp:

load Distinct FileBaseName() as Filename

from

C:\Users\Desktop\Temp\*.qvd(qvd);'This path is where QVD's are placed

For i = 1 to NoOfRows('Temp')

  let filename=FieldValue('Filename',$(i));

  if(right('$(filename)',4)='2014') then

  $(filename):

  load

  * From C:\Users\Desktop\Temp\$(filename).qvd(qvd);

  let path='C:\Users\Desktop\Temp\currentYear\'&'$(filename)'&'.qvd(qvd)';

  store $(filename) into $(path);

  drop table $(filename);

  ELSEIF(Right('$(filename)',4)<2014)then

  $(filename):

  load

  * From C:\Users\Desktop\Temp\$(filename).qvd(qvd);

  let path='C:\Users\Desktop\Temp\previousYear\'&'$(filename)'&'.qvd(qvd)';

  store $(filename) into $(path);

  drop table $(filename);

  end if

next

Regards

Harsha