Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us for a live Q&A! September 21, 10 AM ET - Onboarding Fast in Qlik Sense SaaS! REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
andreip21
Contributor III
Contributor III

load last qvd in folder

Hello all,

How do i load (Qlik script) all columns from the the latest modified ,qvd from a specific folder?

I saw multiple simmilar open topics on Community, but without correct anserws.

Regards,

Andrei

13 Replies
bramkn
Partner
Partner

FOR Each File in FileList('<path>')

AllQVDs:

    LOAD

             '$(File)' AS QVD,

             FileTime('$(File)') AS QVDModifiedDate

    AutoGenerate(1);

Next File

NewestQVD:

FIRST 1 LOAD

     QVD,

     QVDModifiedDate

RESIDENT AllQVDs

ORDER BY QVDModifiedDate DESC;

DROP TABLE AllQVDs;

This will result in a table with 1 record containing the newest QVD

Use Peek or Lookup to get the value of the QVD and load from this path.

hope this was clear enough

View solution in original post

andreip21
Contributor III
Contributor III
Author

all clear until peek/ lookup function

bramkn
Partner
Partner

Peek(field_name[, row_no[, table_name ] ])


So something like this:

Let vLastQVD = Peek('QVD',0,'NewestQVD');

LOAD

*

FROM '$(vLastQVD)' (qvd);

shmulu
Contributor
Contributor

Can you help me in re-writing this for the last n files? Like if it were the last 5? This is what I have so far:

FOR Each File in FileList('FileLocation')

AllQVDs:
LOAD
'$(File)' AS QVD,
FileTime('$(File)') AS QVDModifiedDate
AutoGenerate(1);
Next File

NewestQVD:
FIRST 5 LOAD //determine the newest
QVD,
vFolder & '/' & QVD & '.qvd' as QVDFileName,
QVDModifiedDate
RESIDENT AllQVDs
ORDER BY QVDModifiedDate DESC;

DROP TABLE AllQVDs;


Set vFolder = 'FileLocation';
for each file in filelist(QVDFileName)
load * from [$(vFolder)/$(QVD)/.qvd] (qvd);
next File