Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Set_expression in a variable?

Hi,

just a quick question: When I have a set_expression that I would normally have to copy-paste into all my formulas, approx. 100x in total, can I put that in a variable instead?

How would that have to look?

Can I use it using the $-sign expansion?

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Yes you can put the expression in a variable and yes you need to dollar-expand it where you use the variable.

variable vSum: sum({<Year={2014}>}Amount)

expression using the variable: $(vSum)


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar

Yes you can put the expression in a variable and yes you need to dollar-expand it where you use the variable.

variable vSum: sum({<Year={2014}>}Amount)

expression using the variable: $(vSum)


talk is cheap, supply exceeds demand
whiteline
Master II
Master II

Hi,

Yes, normally you can put any part of expression in a variable.

For example you can put 'Year={2014}, MonthNum={3}' in vBaseSet

And then use in expression: Sum({<$(vBaseSet)>} Value) or  Sum({<$(vBaseSet), Day={1}>} Value).

Even if the speller fails it doesn't mean that expression is incorrect.

The drawback is that later to understand the expression you have to know the variable value.

Also, sooner or later you will have problems with quotes like Dim={'Value'}, sometimes it fails with no reason.

You can even try $-sign expressions with parameters...