Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

boreus-rz
New Contributor

using a variable in Qlik Sense load script

Hello everybody.

I have a table with different entries. First of all, there is a column "id". Now I want to save the data in a .qvd file and add only new data. By concatenate. To identify the new data I would like to do something like: let "vMaxID = max (id);". But this only returns NULL and not the largest previous id. How can I do that?
Thank you for your help.

1 Solution

Accepted Solutions
MVP
MVP

Re: using a variable in Qlik Sense load script

Max(id) has no meaning in this context -- that's why you get a null.

You need to use the script to generate a max and then Peek that into the variable. Like this:

T_Max:

LOAD Max(id) as Maxid

Resident ....

Let vMaxID = Peek('Maxid');

DROP Table T_Max:

    

3 Replies
MVP
MVP

Re: using a variable in Qlik Sense load script

Max(id) has no meaning in this context -- that's why you get a null.

You need to use the script to generate a max and then Peek that into the variable. Like this:

T_Max:

LOAD Max(id) as Maxid

Resident ....

Let vMaxID = Peek('Maxid');

DROP Table T_Max:

    

boreus-rz
New Contributor

Re: using a variable in Qlik Sense load script

Many thanks. This knowledge will significantly speed up my loading script.


Is '$(vMaxID)' the correct way to use the variable in sql select?

MVP
MVP

Re: using a variable in Qlik Sense load script

If it is numeric, then you will not need the quotes

     SQL

     ...

     Where id = $(vMaxID);

If its is text, then

     SQL

     ...

     Where id = '$(vMaxID)';

Community Browser