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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
mikel_de
Creator
Creator

Min and max dates in the script

Hello guys! I frequently use the following script to get the min and max dates from a dataset and store them as variables:

MinMaxDates:

LOAD

  MIN(Date) AS MinDate,

  MAX(Date) AS MaxDate

RESIDENT Data;

LET vMinDate = PEEK('MinDate',-1,'MinMaxDates');

LET vMaxDate = PEEK('MaxDate',-1,'MinMaxDates');


However, I recently stumbled across the following syntax:

MinMaxDates:

LOAD

  MIN(FieldValue('Date', RecNo())) AS MinDate,

  MAX(FieldValue('Date', RecNo())) AS MaxDate

AUTOGENERATE FieldValueCount('Date');

LET vMinDate = Peek('MinDate',-1,'MinMaxDates');

LET vMaxDate = Peek('MaxDate',-1,'MinMaxDates');


What is the difference between both? It seems that they provide the same result. Is the second option better that the first one in any way?


Also why there is no need to reference the table with the Date field when using FieldValue()?


Thanks!

1 Solution

Accepted Solutions
Anonymous
Not applicable

Using FieldValue() can result in better performance, have a look at this https://qlikviewcookbook.com/2013/09/fastest-method-to-read-maxfield-from-a-qvd/

View solution in original post

2 Replies
Anonymous
Not applicable

Using FieldValue() can result in better performance, have a look at this https://qlikviewcookbook.com/2013/09/fastest-method-to-read-maxfield-from-a-qvd/

mikel_de
Creator
Creator
Author

Good read, thank you!