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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
chriys1337
Creator III
Creator III

LET Variable in Script with Set Expression - which does not compute in Frontend

Hi,

I have built a Variable with LET:

LET vL.CF= 'sum({<Index_YearWeek={' & '$' & '(=max(Index_YearWeek))}>}Index_CF_Med)';

In the front end (in a textbox) it comes out like the string aboth (without ' and &), so I put a $-sign around my Variable name $(vL.CF) and it computes the correct number. My question is now, what I have to do, that =vL.CF gives me the number already?

Because I thought LET computes the value already, but in this case not?

Thanks for your help.

Chris

1 Solution

Accepted Solutions
sunny_talwar

Can you check if adding = sign helps?

LET vL.CF = '=sum({<Index_YearWeek={' & '$' & '(=max(Index_YearWeek))}>}Index_CF_Med)';

View solution in original post

4 Replies
sunny_talwar

Can you check if adding = sign helps?

LET vL.CF = '=sum({<Index_YearWeek={' & '$' & '(=max(Index_YearWeek))}>}Index_CF_Med)';

swuehl
MVP
MVP

LET will evaluate your expression and assign the result to the variable.

But your expression is not returning an aggregate (i.e. evaluating the sum() function), but a concatenated string literal.

Besides this, you can't evaluate your aggregation in the script (no set analysis in script) and you can only use aggregation functions in a table LOAD (again, you can of course create a literal that contains the aggregation function as text, like you did).

Hope this clarified the use of LET here.

To answer if you need to add the equal sign or not, is another topic, and it will be dependent on the context you want to finally use your variable in.

The Magic of Variables

The Magic of Dollar Expansions

chriys1337
Creator III
Creator III
Author

So there is no way to compute the result in the script, as you say?

Thank you very much for your effort!

swuehl
MVP
MVP

Not using set analysis and not considering user selections (which will influence 'max week').

If you are fine with static aggregates, that doesn't recompute when the user makes selections, you can precalculate them in the script (using table loads, group by clause and aggregation functions).