Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

create custom function with parameter

How is it possible to create custom function with parameter that you can use in the Expression of chart object avoiding to duplicate n times the same code in all object ?

For example i would like to create this kind of function with 1 parameter $Param1 and reuse it in the expression of several objects :

MyFunction($Param1)

=if(max(Month)<2,'-',

sum({<Month = {"<=$Param1"}*{">$(=$Param1-VRolling_Month)"}*{">=1"}>} [6 - BREAKDOWN LOSS -- Total machine lost time (Hours)])

/

sum({<Month = {"<=$Param1"}*{">$(=$Param1-VRolling_Month)"}*{">=1"}>} [6 - BREAKDOWN LOSS -- Total opening time (Hours)])*100)

End Function

1 Reply
rbecher
MVP
MVP

You cannot define funtions but you can store formulas in variables and pass parameters. Here is a simple example:

Store formula:

var1 = "sum(if(customer=$1 and year=$2,1,0))"

Use in diagram:

=$var1(param1, param2)

Ralf

Astrato.io Head of R&D