Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sorting the filelist function

Hello all,

Can someone explain me, how the filelist function sorts the files ? by name ? by date ? by size ?

is there a way to change the default sort ?

thank you all by advance for your answers

regards

Philippe

1 Reply
Not applicable
Author

Hi Pvivier,

I could not find a simple answer either but gotten round the problem by loading the filenames into a table. E.g.

SET lc_QvdDeltaFiles = $(gc_OutputDir)DeltaBackUp\$(gc_TableName)_*.qvd;

// List all files in Delta files directory
FOR EACH File IN FILELIST('$(lc_QvdDeltaFiles)');
LET ln_NumOfRec = ln_NumOfRec + QVDNOOFRECORDS ('$(File)');

FileTable:
LOAD '$(File)' AS FileName,
FILESIZE('$(File)') AS Size,
FILETIME('$(File)') AS FileTime
AUTOGENERATE 1;
NEXT File;

FileTableSrt:
LOAD FileName,
FileSize,
FileTime
RESIDENT FileTable
ORDER BY FileTime desc;

// Pick at the latest file
LET LatestFile = PEEK('FileName',0,'FileTableSrt');

You can then ORDER BY anything you want. Solution is clunky but works.

Cheers.

Dave.