Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
mikel_de
Contributor

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
Highlighted

Re: Min and max dates in the script

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
Highlighted

Re: Min and max dates in the script

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

Highlighted
mikel_de
Contributor

Re: Min and max dates in the script

Good read, thank you!