Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

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
MVP
MVP

Re: Variables in Qlik Sense

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.

6 Replies

Re: Variables in Qlik Sense

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

Re: Variables in Qlik Sense


Hi Gysbert,

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

Thanks

Re: Variables in Qlik Sense

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


talk is cheap, supply exceeds demand
Not applicable

Re: Variables in Qlik Sense

Hi, Sat,

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

Re: Variables in Qlik Sense

What us the format of MaxFY field?

Feeling Qlikngry?

How To /Missing Manual(18 articles)

MVP
MVP

Re: Variables in Qlik Sense

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.

Community Browser