Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
matthewjbryant
Contributor II

Creating a Variable for the Max Date

I have a script that creates a table of all dates from file names, and I am trying to create a variable from this list to pick out the max date:

For Each vFile in FileList('\D_OO_*.qvd')

FileDates:
Load

Date(Date#(Left(Right('$(vFile)',12),8),'YYYYMMDD'),'DD/MM/YYYY') as [DOO File Date]

autogenerate(1);

Next vFile;


LET vStatisticDate = max([DOO File Date]);

My problem is that for some reason the variable vStatisticDate is null, but when I use the exact same expression after the Load I have no problems. What am I doing wrong?

1 Solution

Accepted Solutions

Re: Creating a Variable for the Max Date

For Each vFile in FileList('\D_OO_*.qvd')

FileDates:
Load

Date(Date#(Left(Right('$(vFile)',12),8),'YYYYMMDD'),'DD/MM/YYYY') as [DOO File Date]

autogenerate(1);

Next vFile;

TMP:
LOAD max([DOO File Date]) as Maxi Resident FileDates;
LET vStatisticDate = Peek('Maxi',0,'TMP');
DROP Table TMP;

4 Replies

Re: Creating a Variable for the Max Date

For Each vFile in FileList('\D_OO_*.qvd')

FileDates:
Load

Date(Date#(Left(Right('$(vFile)',12),8),'YYYYMMDD'),'DD/MM/YYYY') as [DOO File Date]

autogenerate(1);

Next vFile;

TMP:
LOAD max([DOO File Date]) as Maxi Resident FileDates;
LET vStatisticDate = Peek('Maxi',0,'TMP');
DROP Table TMP;

Re: Creating a Variable for the Max Date

Hi

Try like this

MaxDOOFileDate:

Load max([DOO File Date]) as MaxDate

Resident FileDates;


LET vStatisticDate = Peek('MaxDate', 0, 'MaxDOOFileDate');


Drop table MaxDOOFileDate;

Re: Creating a Variable for the Max Date

You need to use Peek in order for this to make it work:

Temp:

LOAD max([DOO File Date]) as MaxDate

Resident FilesDates;

LET vStatisticDate = Peek('MaxDate');

DROP Table Temp;

HTH

Best,

Sunny

matthewjbryant
Contributor II

Re: Creating a Variable for the Max Date

Awesome. Thanks. So is the table not compiled correctly by that point?

Community Browser