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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Looping Error in Qlikview

Hi All,

i want to pick up the Recent file from the Given folder and coding is picking up the recent file as expected

but when i removed the recent file

for example: i have removed the file which is having the data file of - sample_Download_20180209

when i reload the data Qlikview throwing the Error "Cannot open file '\\Naren\in\sample\sample_Download_20180209.CSV'The system cannot find the file specified."

My Doubt is When i removed the Current data file it need to fetch the previous data file from the folder sample_Download_20180208

Coding as Follow:

Let vFilePath ='\\Naren\in\sample\sample_Download_';

FOR EACH file in FileList('$(vFilePath)*.csv');  // Loops each excel file in the given Folder  t

LET vYears = mid(file,26,27);

LET vDates = mid(vYears,14,14);

LET vSM = Rangemax(vDates,vSM);

Next

Sample:

ID,

Name,

Desg

FROM 

[$(vFilePath)$(vSM).csv]

(txt, utf8, embedded labels, delimiter is '|', no quotes, no eof)

loveisfailpcammaertstalwar1luismadrizelixir.seajetqlikcheepirishettyjontydkpikaushalkaushik

4 Replies
tamilarasu
Champion
Champion

Hi,

Try this,

Let vFilePath ='\\Naren\in\sample\sample_Download_';

Let vSM =;

FOR EACH file in FileList('$(vFilePath)*.csv');  // Loops each excel file in the given Folder  t

LET vYears = mid(file,26,27);

LET vDates = mid(vYears,14,14);

LET vSM = Rangemax(vDates,vSM);

Next

Sample:

ID,

Name,

Desg

FROM

[$(vFilePath)$(vSM).csv]

(txt, utf8, embedded labels, delimiter is '|', no quotes, no eof)

tamilarasu
Champion
Champion

You can also try,

Let vFilePath ='\\Naren\in\sample\sample_Download_';

Let vSM =;

FOR EACH file in FileList('$(vFilePath)*.csv');  // Loops each excel file in the given Folder  t

LET vDates = Replace(Subfield(SubField(file,'\',-1),'_',-1),'.csv','');

LET vSM = Rangemax(vDates,vSM);

Next

Sample:

ID,

Name,

Desg

FROM

[$(vFilePath)$(vSM).csv]

(txt, utf8, embedded labels, delimiter is '|', no quotes, no eof)

tresesco
MVP
MVP

stabben23
Partner - Master
Partner - Master

Hi,

what is expected output here?

Have you test this in a texbox With mid function?

LET vYears = mid(file,26,27);  mid(file,1,26) gives you the Whole filename

LET vDates = mid(vYears,14,14);

LET vSM = Rangemax(vDates,vSM);