Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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/
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/
Good read, thank you!