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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
JuMo
Creator
Creator

Local variable in QlikSense Measure

Hello

I have a series of measure that all have almost the same expression. For maintenance purpose I would like to use something like local variable in the expression so that the measure formula is the same (but this variable)

My expression would be:

// My local variable

var = 2

// The calculus

2* var

 

Does something like that exist in QLikSense ?

Labels (4)
1 Solution

Accepted Solutions
madelonjansen
Partner Ambassador
Partner Ambassador

ahh, that's possible as well by using parameters. You can define those as $1, $2 etc:

Set MUL=’$1*$2’;

Let X=$(MUL(3,7)); // returns 21 in X

https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/Scripting/dollar-...

 

View solution in original post

3 Replies
madelonjansen
Partner Ambassador
Partner Ambassador

Sure does!

in the script you could define a variable with:
SET vVar = 2;

And then use it in a calculation as:
2*$(vVar)

In the worksheet this would work much the same. You can use a variable defined in the script, or define one from the worksheet (button in the bottom-left corner) and even use a variable input to let users change the value. Then use it in a calculation in the same way as above.

JuMo
Creator
Creator
Author

Thank you, but that's not exactly what I wanted ...

I want to be able to define this variable Inside the measure expression, not inside the script

madelonjansen
Partner Ambassador
Partner Ambassador

ahh, that's possible as well by using parameters. You can define those as $1, $2 etc:

Set MUL=’$1*$2’;

Let X=$(MUL(3,7)); // returns 21 in X

https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/Scripting/dollar-...