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

How to load only most recent file


Hello,

I'm still getting up to speed on using Qlikview, but ran across an issue that I've been struggling to resolve.  My users place a file into the same folder every day, with the current date appended to the file name.  For example, today's file would be named 28032014MyFile.xls, tomorrow would be 29032014MyFile.xls, 30032014MyFile.xls, ....etc.  The appended date is DDMMYYYY format.

What I'm trying to do is have my load script pull only the most recent file from this folder.  The older files need to remain in the folder for archive reasons, and the users don't want to have to move or rename the old files every day.  But for Qlikview I can use just the current day.  How can I have my load statement use only today's file?

1 Solution

Accepted Solutions
Nicole-Smith

LET vToday = date(today(), 'DDMMYYYY');

LOAD *

FROM $(vToday)MyFile.xls;

View solution in original post

5 Replies
Nicole-Smith

LET vToday = date(today(), 'DDMMYYYY');

LOAD *

FROM $(vToday)MyFile.xls;

alexandros17
Partner - Champion III
Partner - Champion III

let path_Alles = '..\..\qlik\myfile_*.xlsx';

for each File in filelist (path_Alles)

  IF(left(right(File,11),4)<=$(myVar)) then

myTable:

  LOAD

*

  FROM $(File) (ooxml, embedded labels, table is myTab)

  Where mycondition;

  ENDIF

next File

MyVar contains the date of today or what you need

Hope it helps

Anonymous
Not applicable
Author

Thanks, Nicole!  It worked just as i wanted.

chaper
Creator III
Creator III

Hi ,

     I have similar scenario .I have a folder with excel files.I don't want to reload old files every day but want to add new file to QVD?I tried your code but it is not working?Need help

Thanks

sakshikaul
Creator II
Creator II

Hi 

I have similar scenario... i have multiple csv files in a folder and I want to only load most recent files in qvd Not the old one..I am using following code its giving an error 

LET vToday = date(today(), 'DDMMYYYY');
Order_Data:
LOAD distinct
Plant,
OrderNo,
OrderDate,
OrderType,
DistChannel,
Division,
NCODE,
Season,
MatType,
Style,
Color,
Size,
OrderQty,
OrderValue,
ConfirmedQty,
ConfirmedValue,
MRP
FROM $(vToday ) [D:\Qlik_OrderSheets\OrderSheets\QLIK*]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);
store Order_Data into C:\Users\dmsadmin\Desktop\New folder\QVD\extract_qvd\Order_Data.qvd;
drop table Order_Data;