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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Passing functions into variable arguments

I am using variables with arguments to hold my expressions which are used through my application. I pass the variable the respective field to be calculated which works just fine. However, I cannot find a way to pass a function via the argument into the expression without error.

Working example (in simple terms, where Num is the field that holds values):

Normal expression: sum(Num)

Variable for expression: vCalcSum = sum($1)

Called in expression: =$(vCalcSum(Num))

Problem example;  I cannot find a way to pass a function to the same variable, in this case using if():

Normal expression: sum(if(Type=1,Num,0))

Variable for expression (same as above): vCalcSum = sum($1)

Called in expression: =$(vCalcSum(if(Type=1,Num,0)))

I have tried using $ expansion on the inner logic to no avail and am stuck. Thoughts, ideas, tricks??? Thanks!

Labels (1)
2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try set analysis:  $(vCalcSum(  {<Type={1}>} Num  ))


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks. For the simple if() in my example I can use set analysis, but I guess I was looking for a more comprehensive solution that would work for any type of function. Maybe a better example would have been:

if(Type=1,Num,Num*2)

But then again, maybe I'm overthinking this!