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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
michaeldburt
Partner - Contributor III
Partner - Contributor III

Dynamic Load of a QVD

Hello Everyone-

I am trying to write a script that will dynamically choose and load a QVD based on the QVD being the latest loaded version.

For background, I have an app that loads data from a table, and creates a QVD named [Table__$(vTimeStamp)]

In a separate app, I'm trying to load the newest version, or the most current "Timestamp" QVD.

Does anyone have experience with this type of situation?

Labels (1)
1 Solution

Accepted Solutions
swuehl
Champion III
Champion III

You can scan all QVDs in your folder, creating a table with filenames, like

For Each vFile in FileList('$(FolderPath)\Table_*.qvd')

Files:

LOAD '$(vFile)' as Name,

        SubField(Subfield('$(vFile)','_',-1),'.qvd',1) as Timestamp //here you parse the timestamp,may need to adapt, also                                                                                              // using Timestamp#() to interprete as timestamp

AutoGenerate 1;

Next vFile

Then search for max timestamp:

TMP:

LOAD FirstSortedValue( Name, -Timestamp) as LastFileName

Resident Files;

Let vLastFile = Peek('LastFileName',0,'TMP');

View solution in original post

2 Replies
swuehl
Champion III
Champion III

You can scan all QVDs in your folder, creating a table with filenames, like

For Each vFile in FileList('$(FolderPath)\Table_*.qvd')

Files:

LOAD '$(vFile)' as Name,

        SubField(Subfield('$(vFile)','_',-1),'.qvd',1) as Timestamp //here you parse the timestamp,may need to adapt, also                                                                                              // using Timestamp#() to interprete as timestamp

AutoGenerate 1;

Next vFile

Then search for max timestamp:

TMP:

LOAD FirstSortedValue( Name, -Timestamp) as LastFileName

Resident Files;

Let vLastFile = Peek('LastFileName',0,'TMP');

michaeldburt
Partner - Contributor III
Partner - Contributor III
Author

This was exactly what I had in mind.  I had to change the code around a bit but the framework is excellent.  Thank you for the assist!