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: 
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 - Specialist
Partner - Specialist

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

andreip21
Contributor III
Contributor III
Author

all clear until peek/ lookup function

bramkn
Partner - Specialist
Partner - Specialist

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