Qlik Community

Ask a Question

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
April 22, 2PM EST: Learn about GeoOperations in Qlik Sense SaaS READ MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
DSDD
Contributor III
Contributor III

Functions as a variable

Dear community,

i want to let the user choose between average and median in buttons.

So, is it possible to take the Avg and Median function in a variable, let say v_fun?

And how to evaluate functions within the variable on my dimension, let say body_weight? (How does the syntax look like?)

Thanks

Labels (2)
1 Solution

Accepted Solutions
MayilVahanan

Hi @DSDD 

Create a variable and assign the value like below

variable name: v_fun

value: Avg($1)

In chart, ur dimension and expression is like

$(v_fun(body_weight))

-- gives average of body_weight based on ur dimension

Thanks & Regards,
Mayil Vahanan R

View solution in original post

3 Replies
MayilVahanan

Hi @DSDD 

Create a variable and assign the value like below

variable name: v_fun

value: Avg($1)

In chart, ur dimension and expression is like

$(v_fun(body_weight))

-- gives average of body_weight based on ur dimension

Thanks & Regards,
Mayil Vahanan R

View solution in original post

DSDD
Contributor III
Contributor III
Author

Thanks for your answer. It works.

What does $1 achieve in this context, especially when $(v_fun(body_weight)) is evaluated?

MayilVahanan

Hi @DSDD 

$1 here is works like parameter, you can pass any field name.

Thanks & Regards,
Mayil Vahanan R