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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
d_koti24
Creator II
Creator II

How to Load privious qvd?

Hi All,

I have 5 qvds that 5 qvds contains the monthly data.my requirement is i want load the previous qvd's dynamically.

ex:

space201502.qvd

space201503.qvd

space201504.qvd

space201505.qvd

space201506.qvd ----currentmonth

for analysis purpose instead of loading all months data,i want load the only previous 2 months data i.e

space201504.qvd

space201505.qvd

and concatenate to space201506.qvd data.

when july will come i want load

space201505.qvd

space201506.qvd

and concatenate to july data.

when aug comes i want load

space201506.qvd

space201507.qvd

and concatenate to aug data. like this...

how to achive this dynamically??

how to get the last2 previous qvd's name?

regards,

kd.

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

If you use a ForEach vFile in FileList('\\server\qvdfile\space*.qvd construct and parse the date from the filename contained in vFile, then this should be simple enough. Something like:

Let vMinMonth = MonthStart(Today(), -2);

ForEach vFile in FileList('\\server\qvdfiles\space*.qvd')

  Let vBaseFilename = Substring(vFile, '\', -1);

  Let vDate = Date#(Mid(vBaseFilename, 6, 6));

  If vDate >= vMinMonth Then

       Space:

       LOAD *

       FROM [$(vFile)] (qvd);

  End If

Next

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

7 Replies
pokassov
Specialist
Specialist

Hello!

let vFile='space'&date(MonthStart(AddMonths(Today(),-1)),'YYYYMM');

t1:

load *

from $(vFile).qvd;

let vFile='space'&date(MonthStart(AddMonths(Today(),-2)),'YYYYMM');

concatenate(t1)

load *

from $(vFile).qvd;

let vFile='space'&date(MonthStart(Today()),'YYYYMM');

concatenate(t1)

load *

from $(vFile).qvd;

jonathandienst
Partner - Champion III
Partner - Champion III

If you use a ForEach vFile in FileList('\\server\qvdfile\space*.qvd construct and parse the date from the filename contained in vFile, then this should be simple enough. Something like:

Let vMinMonth = MonthStart(Today(), -2);

ForEach vFile in FileList('\\server\qvdfiles\space*.qvd')

  Let vBaseFilename = Substring(vFile, '\', -1);

  Let vDate = Date#(Mid(vBaseFilename, 6, 6));

  If vDate >= vMinMonth Then

       Space:

       LOAD *

       FROM [$(vFile)] (qvd);

  End If

Next

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
d_koti24
Creator II
Creator II
Author

Hi Jonathan,

how to concatenate this months to current month qvd.can u please provide me clear script.

Regards.

jonathandienst
Partner - Champion III
Partner - Champion III

If the field names are the same, it will auto concatenate.

If you load the current month first, then add a concatenate keyword with the existing table name to the load statement:

  If vDate >= vMinMonth Then

       concatenate(Data)

       LOAD *

       FROM [$(vFile)] (qvd);

  End If

If you load the current month last, add a concatenate to that load.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
d_koti24
Creator II
Creator II
Author

For Each vFile in FileList ('\\gma\qv_storage_dev\USERS\99_Koteshwar\space\MONTHLY_QVDS\*.qvd')

  Let vBaseFilename = Substring(vFile,'\',-1);

i am getting script error here...

Let vBaseFilename = Substring(vFile,'\',-1); ---vFile script error here.

regards,

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Maybe you don't have any qvd's in that directory?

Add the following statement between FOR EACH ... and LET vBaseFileName...

TRACE >>> Current filename = '$(vFile)' ;

and run your script again. Then check the log file.

Peter

rubenmarin

Hi koti, try using single quotes for the first parameter of substring:

Let vBaseFilename = Substring('$(vFile)','\',-1); ---vFile script error here.