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: 
Anonymous
Not applicable

Variable not working in some objects

Hello everyone,
 
I created a variable with a set analysis in order to calculate a measure, but it does not work in all the objects of my app. For example, the variable works with a KPI object, but does not work with a bar chart : it gives me the same values for all the dimensions of the bar chart. However, when I use directly the set analysis and not the variable, all the objects including the bar chart work perfectly.
Loading the variable directly from the load editor does not change anything to this problem either.
 
Here is an example :
With set analysis:                                                                                   With variable:
                                           
 
Do you have any idea concerning the origin of the problem?
Many thanks in advance.
1 Solution

Accepted Solutions
marcus_sommer

If you creates a variable with the name x and the content of: sum(AnyValue) without using a leading equal-sign you could use $(x) as expression within the chart as if you have typed sum(AnyValue) there.

- Marcus

View solution in original post

8 Replies
marcus_sommer

I assume that your variable begins with a equal-sign "=" which meant that the expression will be calculated and the result will be stored within the variable. See for this: The Little Equals Sign.

- Marcus

shraddha_g
Partner - Master III
Partner - Master III

how you have defined variable?

Anonymous
Not applicable
Author

Hi Marcus,

Thank you for your reply. My variable begins with the sign = so it calculates the expression and it is not considered as a text (as I understood it from the link you gave me).

It looks like the variable calculates one value and applies it to all the dimensions, even if the variable is created with Let statement.

Anonymous
Not applicable
Author

Hi Shradda, my variable is defined with a Let in a scipt, and looks like this:

=Count( {$< [Field_1]={1},[Field_2] ={1}, [Field_3]={1}> }distinct Field_4)

marcus_sommer

Yes, that's right. By a variable-declaration beginning with the equal sign or within the script per LET will be at first evaluated and only the result of them is stored within the variable and of course each call of the variable has then the same return-value.

- Marcus

Anonymous
Not applicable
Author

Ok, I understand it right now. But does it mean that it is not possible to use variables in bar charts (or other objects with several dimensions), or is there a way to make it work?

marcus_sommer

If you creates a variable with the name x and the content of: sum(AnyValue) without using a leading equal-sign you could use $(x) as expression within the chart as if you have typed sum(AnyValue) there.

- Marcus

Anonymous
Not applicable
Author

Thank you Marcus, it works perfectly 🙂