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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

expression in variable

hi there,

i am using the same expression in multiple charts and want to store the expression simply in a variable and then just reference the variable in the expression of the chart. is that feasible ? I tried vVarName, = vVarName and = $(vVarName), but nothing brought up the result.

Any idea how this could work ?

Thanks in advance.

K

1 Solution

Accepted Solutions
Not applicable
Author

Use

if(Unit = '%', num(Actual, '# ##0%'), if (Unit = '#', num(Actual, '#0'), num(Actual, '## ##0.00') ))

in your variable (without "=") and use

=$(vVariable)

in chart expression

View solution in original post

6 Replies
Not applicable
Author

try with sinply vVarName where vVarName is declared as: =Sum(Value)

Not applicable
Author

It seems to work if i have only one record in my chart selected. But having nothing selected the expression returns NULL....

Not applicable
Author

OK, let me get my crystal globe and guess your structure, data and what you want to achieve...

Not applicable
Author

you dont need a chrystal globe - its simple:

a) you have a table

InitiativeActualCountryUnit
Initiative A100.000US$
Initiative B50.000CAN$
Initiative C125.000EUR$
Initiative D24EUR%
Initiative E2EUR#

b) you have a pivot chart with Initiative & Country as Dimensions

c1) you have as Expression (in the pivot table):

     = if(Unit = '%', num(Actual, '# ##0%'), if (Unit = '#', num(Actual, '#0'), num(Actual, '## ##0.00') ))

--> works fine

c2) you have the expression above in variable and the variable in the chart expression, then it only works when you have one record of the chart selected.

chrystal clear ?

Not applicable
Author

Use

if(Unit = '%', num(Actual, '# ##0%'), if (Unit = '#', num(Actual, '#0'), num(Actual, '## ##0.00') ))

in your variable (without "=") and use

=$(vVariable)

in chart expression

Not applicable
Author

Merci!