Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
markgraham123
Specialist
Specialist

Load qvd by timestamp in script

Hi,

I'm working on areq. where there were 20-30 Qvd files with same name but diff. time stamp.

YYYYMMDDFIlename.Qvd

Need to select the latest Qvd for the reload.

Can anyone pls help me in loading the latest qvd dynamically.

23 Replies
markgraham123
Specialist
Specialist
Author

Hi Sunny,

Can i know why is it mentioned Resident Table in Date:

When we r nt fetching anything from table.

sunny_talwar

My bad:

Date:

LOAD Num(Today() - x) as Date //where x needs to be an integer

AutoGenerate 1;

LET vMaxDate = Date(Peek('MaxDate'), 'YYYYMMDD');

DROP Tables Table, MaxDate;

FinalTable:

LOAD *

FROM $(vMaxDate)ABCDEN00.qvd (qvd);

markgraham123
Specialist
Specialist
Author

Is this right?

Table:

First 1

LOAD FileName() as File,

  Date#(Left(FileName(), 8), 'YYYYMMDD') as Date

FROM *ABCDEN00.qvd (qvd);

MaxDate:

LOAD Max(Date) as MaxDate

Resident Table;

Date:

LOAD Num(Today() - x) as Date //where x needs to be an integer

Resident Table;

LET vMaxDate = Date(Peek('MaxDate'), 'YYYYMMDD');

DROP Tables Table, MaxDate;

FinalTable:

LOAD *

FROM $(vMaxDate)ABCDEN00.qvd (qvd);

sunny_talwar

No just use this:

Replace x with the number of days back you will have your most recent qvd to be. If its today's qvd then x = 0, yesterdays x = 1 and so on...

Date:

LOAD Num(Today() - x) as Date //where x needs to be an integer

AutoGenerate 1;

LET vMaxDate = Date(Peek('MaxDate'), 'YYYYMMDD');

DROP Tables Table, MaxDate;

FinalTable:

LOAD *

FROM $(vMaxDate)ABCDEN00.qvd (qvd);

markgraham123
Specialist
Specialist
Author

So, in this case, we donot need to load the "Table" at first where we r using Drop Tables Table, Date;

sunny_talwar

Yup, you are right, no need to drop Table Just use Drop Table Date;

sunny_talwar

Making too many silly mistakes today

markgraham123
Specialist
Specialist
Author

1111.png

sunny_talwar

Can you paste a screenshot of your script, where you are doing this:


Date:

LOAD Num(Today() - x) as Date

AutoGenerate 1;

LET vMaxDate = Date(Peek('MaxDate'), 'YYYYMMDD');

markgraham123
Specialist
Specialist
Author

Sunny, its working

Small editing...

Its LET vMaxDate = Date(Peek('Date'), 'YYYYMMDD');


we were using LET vMaxDate = Date(Peek('MaxDate'), 'YYYYMMDD');

where der is no 'MaxDate'.. we have only 'Date'