Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Weird behaviour when using variables in chart expressions

I have an expression thtat is repeated a lot in my document and it is the following:

=sum({$<[Type] = {'type_A'}>}if(duration > 0.0, 1,0))

so I put it into a variable called totalbreakdown.

If I use that variable for one of my expressions in the chart (tab expressions) and I assign the variable to it in field definition as below:

totalbreakdown


then I do not get the same result in chart that if I put the complete expression in the field definition:

=sum({$<[Type] = {'type_A'}>}if(duration > 0.0, 1,0))


So why¿?

3 Replies
migueldelval
Specialist
Specialist

Hi Tony,

Try with this.

=sum({$<[Type] = {'type_A'}>}if(duration > 0.0, duration,0))


You need to change 1 fort your measure, because 1 only express that you want to show something, but aren´t using any measure.


Regards


Miguel del Valle

swuehl
MVP
MVP

The result might be depending on the way you are defining your variables and how you call them:

The Magic of Variables

The Little Equals Sign

Not applicable
Author

Hi, Miguel,

With this expression I am trying to get the number of tuples of type "Type_A" which have a duration value greater than 0.0 so no need to change 1 by duration. Changing by duration you are obtaining the sum of all duration that complains duration > 0.0 and this is not what I want. Anyway my problem is that my chart is displaying different values depending on the value I assign to one of the expressions, if I assign the variable it displays a result that is different from the result that is displayed when I put the variable content directly.

Thanks in advance!