Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
all clear until peek/ lookup function
Peek(field_name[, row_no[, table_name ] ])
So something like this:
Let vLastQVD = Peek('QVD',0,'NewestQVD');
LOAD
*
FROM '$(vLastQVD)' (qvd);
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