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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
balaji_m
Partner - Contributor III
Partner - Contributor III

Loading selective qvds from particular folder

Hi ,

I want to load last 5 qvds created by monday.

Please find attached here with list of QVDs.

i want to load below qvds.based on today date.In file name WK_1 stands for monday file.


Load * From .\filename1_WK_1*.qvd...

I am able to filter monday qvds using above load statement.

filename1_WK_1_26_Feb_2018

filename1_WK_1_05_Mar_2018

filename1_WK_1_12_Mar_2018

filename1_WK_1_19_Mar_2018

filename1_WK_1_26_Mar_2018


Regards,

Balaji

5 Replies
binujose1982
Contributor III
Contributor III

Hi Balaji,

Please use below script;

SET dir="C:\Test\";

for each file in filelist(dir&'filename1_WK_1*.qvd')

tempTable:

LOAD *    

FROM

$(file)

(qvd);

next file

Regards,

Binu

jonathandienst
Partner - Champion III
Partner - Champion III

I am not sure what you want to know. You are already filtering for Monday as far as i can tell from your post.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
balaji_m
Partner - Contributor III
Partner - Contributor III
Author

Hi Jonathan,

I want to load last 5 monday qvds.


Can you please let me know how to filter?

Regards,

Balaji

boorgura
Specialist
Specialist

FileList:

NoConcatenate

LOAD * Inline [

File, Date

];

for Each vFile in FileList('filename1_WK_1_*.qvd')

Concatenate(FileList)

LOAD '$(vFile)' as File,

date(date#(left(right('$(vFile)', 15), 11), 'DD_MMM_YYYY')) as Date

AutoGenerate(1);

NEXT

inner join(FileList)

First 5

LOAD

Date

Resident FileList

Order By Date desc;

FileList will have the latest 5 files, along with the corresponding Dates.

jonathandienst
Partner - Champion III
Partner - Champion III

Scan the folder and store the results in reverse order, then load the first 5:

Set vFiles = '';

For Each vFile in FileList('.\filename1_WK_1*.qvd')

     Let vFiles = vFile & If(Len(vFiles), ',' & vFiles);

Next

Table:  // table stub for concatenation

LOAD '' as Source AutoGenerate 0;

For i = 1 To 5

     Let vFile = SubField(vFiles, i);

     If Len(vFile) > 0 Then

          Concatenate(Table)

          LOAD *, FileBaseName() as Source

          FROM [$(vFile)] (ooxml, ...);

     End If

Next

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein