Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
ArjunPrasad
Contributor III
Contributor III

Creating expression using variable in script

Hi All,

I am trying to create one expression in script using Let or Set variable but not getting expected output.

i a have a master calendar Year field 

Set vSales = 'Sum({<Year={"$(=Max(Year))"}>}SalesAmount)';

Above expression not working, applied in table expression like : $(vSales)

Set vSales = 'Sum({<Year={1998}>}SalesAmount)';  // This is working

not able figured it out , please suggest me.

Thanks

Arjun

1 Solution

Accepted Solutions
tresB
Champion III
Champion III

One way could be using LET, like:

Let vSales = 'Sum({<Year={'&'"$'&'(=Max(Year))"}>}SalesAmount)';

View solution in original post

4 Replies
tresB
Champion III
Champion III

One way could be using LET, like:

Let vSales = 'Sum({<Year={'&'"$'&'(=Max(Year))"}>}SalesAmount)';

ArjunPrasad
Contributor III
Contributor III
Author

Thank u Tresesco its working now.😊

but why we using like  { '&'"$'&'(=Max(Year))"}

cant we use like this {"$(=Max(Year))"}  //its not giving any value either.

Can you please let me know.

Thanks,

Arjun

tresB
Champion III
Champion III

Short answer, '$' gets evaluated in the script as well. Therefore, you have to suggest qlik engine that '$' for this case is not for expansion but treat it as a string/char.

ArjunPrasad
Contributor III
Contributor III
Author

Thank u for clarification @tresB .