Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Broly21000
Contributor
Contributor

set the min and max date value in variable

Hi , 

Hello,
I want to retrieve the minimum and maximum date to store it in a variable, but the variable is empty each time.
can someone please help me

Temp:
LOAD

      Min(Date) as MinDate,

      Max(Date) as MaxDate

FROM [lib://QlikSense/MyFolder/MyQvd.qvd](qvd) ;

LET vMinDate = peek('MinDate');

LET vMaxDate = peek('MaxDate');

TRACE 'vMinDate'+$(vMinDate);
TRACE 'vMaxDate'+$(vMaxDate);

 

Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

It looks like it should work as written. It may be that the Date field is a Text value, not a numeric date value. In that case you will have to convert the Date as you read with

Min(Date#(Date, 'DD/MM/YY')) 

where DD/MM/YY is whatever your text date format is. 

-Rob

View solution in original post

5 Replies
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

 

If you try with more parameter :

 

LET vMinDate = peek('MinDate', 0);

LET vMaxDate = peek('MaxDate', 0);

 

Aurélien

Help users find answers! Don't forget to mark a solution that worked for you!
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

It looks like it should work as written. It may be that the Date field is a Text value, not a numeric date value. In that case you will have to convert the Date as you read with

Min(Date#(Date, 'DD/MM/YY')) 

where DD/MM/YY is whatever your text date format is. 

-Rob

SunilChauhan
Champion II
Champion II

Temp:
LOAD

      Min(Date) as MinDate,

      Max(Date) as MaxDate

FROM [lib://QlikSense/MyFolder/MyQvd.qvd](qvd) ;

LET vMinDate = peek('MinDate',0,Temp);

LET vMaxDate = peek('MaxDate',-1,Temp);

TRACE 'vMinDate'+$(vMinDate);
TRACE 'vMaxDate'+$(vMaxDate);

 

See the attched File as a sample , I am using Inline Table , You Can use pour  Qvd.

Sunil Chauhan
Thanmughi_Sudaroli
Partner - Contributor
Partner - Contributor

Hi,

Please try the below code.

Temp:
LOAD

      Min(Date) as MinDate,

      Max(Date) as MaxDate

FROM [lib://QlikSense/MyFolder/MyQvd.qvd](qvd) ;

LET vMinDate = peek('MinDate',0,'Temp');

LET vMaxDate = peek('MaxDate',0,'Temp');

Trace $(vMinDate );

Trace $(vMaxDate );

Drop table Temp;

oskartoivonen
Partner - Contributor III
Partner - Contributor III

Assuming you've checked that MinDate and MaxDate fields return an appropriate value, using the Peek()-function outside a LOAD-statement requires that you use all 3 arguments: field_name, row_no and table_name.