Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
boreus-rz
Contributor II
Contributor II

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
jonathandienst
Partner - Champion III
Partner - Champion III

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:

    

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

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:

    

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
boreus-rz
Contributor II
Contributor II
Author

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


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

jonathandienst
Partner - Champion III
Partner - Champion III

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

     SQL

     ...

     Where id = $(vMaxID);

If its is text, then

     SQL

     ...

     Where id = '$(vMaxID)';

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein