Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to use variable in set analysis ?

Hello everyone,

In my application, there are data for several years and I would like to show in a graph only the last 3 years (current one + 2 laters).

So I created a variable : vCurrentYear = max(MyYear)    // MyYear is a field in my calendar that goes until the date of execution.

If I put =$(vCurrentYear)  in a textbox, I do get 2015.

In my graph, in the expression tab, I have entered  in order to get the sum of Cpt_abt for the past 3 years.

sum({$<Year_S={">=$(vCurrentYear)-2"}>}Cpt_abt)

But I get the message "No data to display".

If instead, I put

sum({$<Year_S={">=2013"}>}Cpt_abt)   , I do get my graph.

I am guessing there must be something wrong with the quotations marks but I cannot find the proper way to write my expression..

Any ideas ?

Thank you for your help

12 Replies
Not applicable
Author

This works ! Thank you !

Now, I would like to understand what does the equal sign do ? What does "evaluate globally" mean ? I I don't put the equal sign, it is "locally" evaluated ?

jonathandienst
Partner - Champion III
Partner - Champion III

Without the = sign, you are inserting the expression and the expression is evaluated after expansion. That's why you use =$(var) in the text box. The expression is expanded and then evaluated.

With the = sign, the variable is evaluated continuously and the value itself is inserted. Now you can use

=var in the text box, because var has already been calculated.

HTH

Jonathan

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