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

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to define a new function?

Hi all,

since I have a complex calculation that I reuse in charts, I would like to put into a variable the results of the calculation, but I would like to define dinamically the set of values of the fields on which to perform the calculation.

It looks like defining a new function: is it possible (perhaps using set Analysis in variable definition)?

Thanks in advance!

Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can define a variable as an expression that uses parameter placeholders. See the section "Dollar-Sign Expansion with Parameters" in the Ref Guide.

For example

SET myfunc= $1 + $2;

$(myfunc(3,4)) = 7

See also the attached example from the QV Cookbook.

-Rob

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can define a variable as an expression that uses parameter placeholders. See the section "Dollar-Sign Expansion with Parameters" in the Ref Guide.

For example

SET myfunc= $1 + $2;

$(myfunc(3,4)) = 7

See also the attached example from the QV Cookbook.

-Rob

Not applicable
Author

Thanks a lot Rob!

It's very useful and very clear!

Roberta