KPI - Saved Formulas
Description
Saved formulas are reusable PQL statements which can be defined in the frontend. With KPI
a saved formula can be called. The result is the same as if the saved formula would have been directly placed where KPI is called.
Syntax
Saved formulas can have parameters. The same parameter can be used multiple times in the saved formula. The syntax to define a parameter is as follows:
{p<index>}
index: number of parameter. Begins with one and has to be consecutive, otherwise an error will show up.
The syntax to call a saved formula is as follows:
KPI ( formula_name (, argument )* )
formula_name: Case sensitive name of the formula as string constant
argument: column | constant | operator | filter/logical expression | VARIABLE( value ) The parameter in the KPI is replaced by the corresponding argument. If the parameter represents a column, constant, operator or filter/logical expression then the corresponding column, constant, operator or filter/logical expression can be passed as an argument directly. Otherwise VARIABLE( value ) has to be used, where value are arbitrary characters. For example if the parameter represents a list, that should be passed as one single argument or an operator name.
Operator precedence
When a saved formula is called, the saved formula is evaluated first. This means that implicit parenthesis around the saved formula statement are assumed.
Default Saved Formulas
A set of predefined saved formulas is provided. Here is shown how they are implemented:
Process variants:
SHORTENED ( VARIANT ( activity_column ) )
Number of process variants:
COUNT ( DISTINCT SHORTENED ( VARIANT ( activity_column ) ) )
Ratio:
AVG ( CASE WHEN {p1} THEN 1 ELSE 0 END )
Filtered count:
COUNT ( CASE WHEN {p1} THEN 1 ELSE NULL END )
Examples
[1] Simple example in which a saved formula without a parameter is called. The saved formula returns a string constant. | ||||||
| ||||||
|
[2] In this example a saved formula with two parameters is called. For the first parameter the optional keyword VARIABLE is used. Besides that there is no difference between the first and the second parameter. | ||||||
| ||||||
|
[3] Here a saved formula with one variable parameter in IN operator is called. The parameter uses the optional keyword VARIABLE to specify that the input list is only one parameter. | ||||||||||||||
| ||||||||||||||
|
[4] Even tough the parameters have to be consecutively numbered, they don't have to appear in that order in the saved formula. This is shown in the following example. | ||||||
| ||||||
|
[5] Here a saved formula is defined which uses the same parameter twice. | ||||||
| ||||||
|
[6] Here a saved formula containing an addition is defined. Due to implicit parenthesis around the saved formula, the addition is evaluated before the multiplication. | ||||||
| ||||||
|