Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load files into QV in Descending Order

Hi

Have any of you found a way to load files into Qlikview in descending order?

I have over 100 csv files (all have the same structure) with sales data that I need to load into a QVD.

Each csv files has 8 days worth of data, so we can expect a sales order to appear 8 times.

I want to load these files in descending order so that I load the most recent occurrence of the order first and then ignore the duplicates by using the EXISTS command in QV.

If I run the load normally, it loads the oldest file first and therefore keeps the oldest version of the sales order.

I need to keep the most recent version and I do not want to load these files 1 at a time.

1 Reply
Not applicable
Author

Hi,

You could do an initial load of just the filenames, then using a for loop and peek, load them in reverse order. Here's what I mean in sudo-code:

sourcefiles:

LOAD

     filename() as csv_file

FROM [*.csv];

For i = 0 to NoOfRows('sourcefiles')

     Let reverseRowId = NoOfRows('sourcefiles')-$(i);

     Let fileToLoad = peek('csvFile',$(reverseRowId),'sourcefiles');

    

     LOAD

         fields

     FROM [$(fileToLoad).csv]

     Where Not Exist(ID);

Next

Sorry, it's a bit rushed, so I apologise if I've made a mistake, but hopefully the principle will work for you.