Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variables in Qlik Sense

Hi

I was trying to create a variable using peek() function in Qlik sense Script editor. But no value was assigned to the variable. Can someone please help me here?

MaxYear:
LOAD MaxFY
FROM
[lib://Documents/MaxFY.qvd]
(qvd);

let vMaxYear= peek('MaxFY');
let vLastYear=$(vMaxYear)-1;

Thanks

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Seems you are getting the max value, why can't you use Max() in load script like below

MaxYear:
LOAD Max(MaxFY) AS MaxFY
FROM
[lib://Documents/MaxFY.qvd]
(qvd);

let vMaxYear= peek('MaxFY');
let vLastYear=$(vMaxYear)-1;

Peek() always gives you the last value read, if the last value is null then you won't get any value in Peek().

Hope this helps you.

Regards,

jagan.

View solution in original post

6 Replies
Gysbert_Wassenaar

Does a table named MaxYear exist after the script is executed and does the last row of that table contain a value in the field MaxFY?


talk is cheap, supply exceeds demand
Not applicable
Author


Hi Gysbert,

Thanks for your quick response. Yes, MaxYear table is existed after script execution and also MaxFY has the value.

Thanks

Gysbert_Wassenaar

Does the variable vMaxYear have a value? Can you post the MAXFY.qvd file?


talk is cheap, supply exceeds demand
Not applicable
Author

Hi, Sat,

let vMaxYear= peek('MaxFY',-1,'MaxYear');

robert_mika
Master III
Master III

What us the format of MaxFY field?

Feeling Qlikngry?

How To /Missing Manual(18 articles)

jagan
Luminary Alumni
Luminary Alumni

Hi,

Seems you are getting the max value, why can't you use Max() in load script like below

MaxYear:
LOAD Max(MaxFY) AS MaxFY
FROM
[lib://Documents/MaxFY.qvd]
(qvd);

let vMaxYear= peek('MaxFY');
let vLastYear=$(vMaxYear)-1;

Peek() always gives you the last value read, if the last value is null then you won't get any value in Peek().

Hope this helps you.

Regards,

jagan.