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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
ijulias
Contributor II
Contributor II

Use expression as a variable parameter

Hi everybody,


I've defined the variable "vArrodoniment" like this:

if($1>20,num($1,'##.##0'),if($1>1,num($1,'##.##0,0'),num($1,'##.##0,00')))

So, it has different correct results:

=$(vArrodoniment(0.05)) ---> 0,05
=$(vArrodoniment(10)) ---> 10,0
=$(vArrodoniment(22)) ---> 22

Now, I would like to pass a parameter as a result of a function instead of a hardcoded number.

I've the expression:

=$(=Only({1<Codi_Indicador={'83'}>} formula_municipi_any))

It's ok and it results 71,12.

So I would like to use this expression as the parameter of the variable vArrodoniment.

I use it inside like this.

=$(vArrodoniment($(=Only({1<Codi_Indicador={'83'}>} formula_municipi_any))))

And there is the next error "Error: Error in expression: '}' expected ".

Anybody knows if it's possible to use the result of an expression as a parameter of a variable?

 

Thanks a lot!

Labels (1)
1 Solution

Accepted Solutions
MarkWillems
Contributor III
Contributor III

I got this to work by putting the Only() function in it's own hidden expression within a straight table and then referencing it within the variable function call, which sits within it's own expression:

 

=$(vArrodoniment("Hidden Expression name"))

 

Putting the expression directly within the call to the variable would not give me an error, but it would also sum all the figures in a table for each row in the table and ignore the dimensions entirely.

Hey, Please don't forget to add kudos, like or mark as a solution if my reply has helped you at all! 🙂

View solution in original post

2 Replies
MarkWillems
Contributor III
Contributor III

I got this to work by putting the Only() function in it's own hidden expression within a straight table and then referencing it within the variable function call, which sits within it's own expression:

 

=$(vArrodoniment("Hidden Expression name"))

 

Putting the expression directly within the call to the variable would not give me an error, but it would also sum all the figures in a table for each row in the table and ignore the dimensions entirely.

Hey, Please don't forget to add kudos, like or mark as a solution if my reply has helped you at all! 🙂
ijulias
Contributor II
Contributor II
Author

Thanks MarkWillems,

I've several cases I wanted to use the same solutions; some of them I've got the same result as you, and another are so difficult because every execution of the variable Qv try to execute it in a context that sometimes is not the desired.

At the end, I've used the pass variable parameter in one case.