Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
tab1:
load * Inline
[Date, Country, Product, Amount
2022-01-20, Canada, Washer, 6
2018-07-08, Germany, Anchor bolt, 10
2018-07-14, Germany, Anchor bolt, 3
2018-08-31, France, Nut, 2
2018-09-02, Czech Republic, Bolt, 1
2019-02-11, Czech Republic, Bolt, 3
2019-07-31, Czech Republic, Washer, 6
2020-03-13, France, Anchor bolt, 1
2020-07-12, Canada, Anchor bolt, 8
2020-09-16, France, Washer, 1];
tab2:
load max(Date) as maxdate resident tab1;//here max(Date) has numeric date value 44581, but variable max(Date) is not returning any value
let vmaxdate=Peek('maxdate');
let v1=max(Date);
let v2='=max(Date)';
let v3=Num(max(Date));
let v4=Peek('maxdate');
trace v1 is $(v1), v2 is $(v2), v3 is $(v3),v4 is $(v4);
None of my variables (v1,v2,v3,v4) have date values except v4 which uses peek with maxdate.
I want to know why.Can someone please explain
In script, Peek() may be used outside a load statement. Max() may not. The functions Peek() and Max() are two quite different things.
"Peek() returns the value of a field in a table for a row that has already been loaded".
https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/InterRecordFun...
"Max() finds the highest numeric value of the aggregated data in the expression, as defined by a group by clause".
https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFun...
-Rob
In script, references to fields must be used in a Load statement to have meaning.
max(Date)
by itself will return null because there are no Date values.
load max(Date) as maxdate resident tab1;
uses the Date values from table tab1.
In a chart, "max(Date)" works because in the UI, all data and fields are available. There is no table reference.
-Rob
Hi ,
Thanks for the quick reply
Peek is also used on field maxdate .Peek is not used in load statement .But still,it is working. I am confused
Instead of Peek, if I use Num function as Num(maxdate) again it is not working.
How come Peek is working and Num is not working?
let v4=Num('maxdate');
In script, Peek() may be used outside a load statement. Max() may not. The functions Peek() and Max() are two quite different things.
"Peek() returns the value of a field in a table for a row that has already been loaded".
https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/InterRecordFun...
"Max() finds the highest numeric value of the aggregated data in the expression, as defined by a group by clause".
https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFun...
-Rob
Thanks Rob. It is clear now.