Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
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

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/

2 Replies

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/

mikel_de
Contributor

Re: Min and max dates in the script

Good read, thank you!