Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
surajap123
Creator III
Creator III

load latest file based on todays date

Hi There,

I have the filename in the below format and I want to only load the file if it belongs to today's date in the folder. If not, then don't load.

FileName:
DataFile_YYYYMMMDD.xlsx
eg- DataFile_2022Mar15.xlsx

 

Please help

Labels (2)
1 Solution

Accepted Solutions
Or
MVP
MVP

Let vFileName = 'YourPathHere\DataFile_' & date(today(),'YYYYMMDD' & '.xls';

If NOT isnull(FileSize('$(vFileName )') THEN

// Load stuff here

END IF

Have a look at https://community.qlik.com/t5/QlikView-App-Dev/How-can-I-check-if-a-file-exists/td-p/518834 - the rest is just building the correct string for your file path and name.

View solution in original post

3 Replies
Or
MVP
MVP

Let vFileName = 'YourPathHere\DataFile_' & date(today(),'YYYYMMDD' & '.xls';

If NOT isnull(FileSize('$(vFileName )') THEN

// Load stuff here

END IF

Have a look at https://community.qlik.com/t5/QlikView-App-Dev/How-can-I-check-if-a-file-exists/td-p/518834 - the rest is just building the correct string for your file path and name.

surajap123
Creator III
Creator III
Author

Thank you so much for your help.  It solves my issue. 

Just wondering if the latest file is not available, i want to pick Yesterday's file. How can i add that to the code?

Or
MVP
MVP

Add an ELSE section to your IF THEN block, set the vFileName to yesterday's file which would be today()-1, and then load that.