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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using Expression Value in Chart Segment Setup

I have a pretty complex expression in a gauge chart with only one segment color. I would like to change the color of that segment if the value of my one expression is > 100. I know I can do this by using the same expression in my calculated segment color, but I don't like the overhead that comes with it. Is there a way to just reference the expression name?

Ex. =if(myExpressionName > 100, RGB(1,1,1), RGB(2,2,2))

1 Solution

Accepted Solutions
cesaraccardi
Specialist
Specialist

That's fine You don't need to create the variable in the script, just click on Settings tab / Variable Overview. Then click add and give a name to your variable, after that you can paste your expression in the definition pane. Don't forget to put a = before the expression.

View solution in original post

5 Replies
cesaraccardi
Specialist
Specialist

Hi Adam,

What about storing the expression in a variable and then using it in your condition?

Not applicable
Author

Good thought Cesar, but due to the nature of the expression, I can't create the equivalent in script execution to assign to a variable. Well, at least, I don't know how

cesaraccardi
Specialist
Specialist

That's fine You don't need to create the variable in the script, just click on Settings tab / Variable Overview. Then click add and give a name to your variable, after that you can paste your expression in the definition pane. Don't forget to put a = before the expression.

Not applicable
Author

Holy Cow! I was not aware I could do that!

What is the cost of using variables in this way with complex expressions? For instance:

Option 1:

     I have the complex expressions in a chart that is isolated to one tab, where the calculations in the expression are only done when on that tab.

Option 2:

     Assign the complex expressions to a couple variables at the document level that would be calculated in every tab after every selection.

So would Option 2 cost more processor? Or am I thinking of this in the wrong way?

cesaraccardi
Specialist
Specialist

When you have the expression in a variable it's re-calculated every time you make a selection whereas when you use it on an specific chart it will only calculate when the chart is displayed. So, if you need this calculation in many objects you could stick it into a variable just to ease maintenance as it would be recalculated many times anyway. So yes, I think you are right in saying that.