Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

lightsection
New Contributor III

Filelist loop not working

Hi All,

The below chunk of code does not give me the desired output. I am trying to skim through all filenames in a folder and extract the maximum date. Please let me know what might be wrong here:

// -----------------------------------------------------------

Let vMaxMonthYear = MakeDate(1900);

For Each vFile in FileList('$(viTimeSQLExtracts)' & 'IPower_Monthly*.qvd')

  Let vCurMonthYear =  MonthEnd(MakeDate(subfield('$(vFile)', '_', 3), subfield('$(vFile)', '_', 4)));

  If $(vCurMonthYear) > $(vMaxMonthYear) then

    LET vMaxMonthYear = $(vCurMonthYear);

  End If

Next vFile

// For testing purpose only

Let vTest_CurMonthYear =  MonthEnd(MakeDate(subfield('$(vFile)', '_', 3), subfield('$(vFile)', '_', 4)));

Trace $(vTest_CurMonthYear);

Trace 'Latest Month: $(vMaxMonthYear)';

Tags (1)
1 Solution

Accepted Solutions
Employee
Employee

Re: Filelist loop not working

You should check viTimeSQLExtracts variable.

Does it contains the full path to your qvd´s?

2 Replies
Employee
Employee

Re: Filelist loop not working

You should check viTimeSQLExtracts variable.

Does it contains the full path to your qvd´s?

lightsection
New Contributor III

Re: Filelist loop not working

Yes, that was the culprit. Apparently if the variable is not able to find the path, it doesn't throw an error.

Thanks for the help.

Community Browser