Calculated metrics allow you to create calculations based on the attributes of process steps or custom attributes. Various operators and expressions are available to create a calculation rule for a metric.
You can calculate the duration between two steps.
You can calculate with custom attributes (addition, subtraction).
Currently it is only possible to offset numbers against each other.
If you need further help with the implementation of your calculations, do not hesitate to contact your Scheer PAS consultant.
Available Operators
The following table shows the available operators:
Operator | Description | Structure |
---|
OperatorAddition | Allows the addition of expression2 and expression1. |
CODE
"type": "OperatorAddition",
"expression1": {},
"expression2": {}
|
OperatorAttribute | Allows to extract an attribute (second operand) from the first node of a set of process nodes. This set of process nodes is itself the result of an expression (first operand). Possible values for expression2: start, end, name (of a process step).
|
CODE
"type": "OperatorAttribute",
"expression1": {},
"expression2": {}
|
OperatorDivision | Allows to divide expression1 by expression2. |
CODE
"type": "OperatorDivision",
"expression1": {},
"expression2": {}
|
OperatorEquals | Allows the comparison of expression1 and expression2. |
CODE
"type": "OperatorEquals",
"expression1": {},
"expression2": {}
|
OperatorIndex | Allows to extract the process node at a given index (second operand) from a set of process nodes. This set of process nodes is itself the result of an expression (first operand). |
CODE
"type": "OperatorIndex",
"expression1": {},
"expression2": {}
|
OperatorMultiplication | Allows to multiplicate expression1 and expression2. |
CODE
"type": "OperatorMultiplication",
"expression1": {},
"expression2": {}
|
OperatorProcessAttribute | Allows to extract custom attributes from the given process. |
CODE
"type": "OperatorProcessAttribute",
"expression": {}
|
OperatorSubtraction | Allows to subtract expression2 from expression1. |
CODE
"type": "OperatorSubtraction",
"expression1": {},
"expression2": {}
|
Available Expressions
The following table shows the available expressions:
Expression | Description | Structure |
---|
FilterAttribute | |
CODE
"type": "FilterAttribute",
"expression": {}
|
FilterIndex | |
CODE
"type": "FilterIndex",
"expression": {}
|
FilterType | |
CODE
"type": "FilterType"
|
LocationPath | A LocationPath is a set of LocationSteps to be applied on the evaluation context. |
CODE
"type": "LocationPath",
"steps": []
|
LocationStep | |
CODE
"type": "LocationStep",
"axis": <>,
"nodeTest": <>,
"filters": <>
|
ValueBoolean | Represents a boolean value or operand for operating expressions. |
CODE
"type": "ValueBoolean",
"value": <>
|
ValueNumber | Represents a number value or operand for operating expressions. |
CODE
"type": "ValueNumber",
"value": <>
|
ValueString | Represents a string value or operand for operating expressions. |
CODE
"type": "ValueString",
"value": <>
|
Calculation Rule Examples
Currently it is only possible to offset numbers against each other.
Calculating the Duration Between two Steps
Use Case | You want to calculate the duration between step1 and step2. Each step is passed only once. |
---|
Description | To subtract two values, you need the OperatorSubtraction. The operator needs expression1 and expression2. For each expression you have to extract the correct attribute/value from a process node. To do so, you need the OperatorAttribute. expression1 extracts the correct step and expression2 gets the correct value from this step. Then you need the LocationPath expression. Fill the steps array with the process step you need. Add this step to the property nodeTest . You also have to indicate the direction, descendant would be the default.
|
---|
Example Calculation Rule |
CODE
{
"type": "OperatorSubtraction",
"expression1": {
"type": "OperatorAttribute",
"expression1": {
"type": "LocationPath",
"steps": [{
"type": "LocationStep",
"axis": "descendant",
"nodeTest": "step2"
}]
},
"expression2": {
"type": "ValueString",
"value": "start"
}
},
"expression2": {
"type": "OperatorAttribute",
"expression1": {
"type": "LocationPath",
"steps": [{
"type": "LocationStep",
"axis": "descendant",
"nodeTest": "step1"
}]
},
"expression2": {
"type": "ValueString",
"value": "end"
}
}
}
|
---|
Adding two Values
Use Case | You want to add CustomAttribute1 and CustomAttribute2. |
---|
Description | To add two attributes, you need the OperatorAddition. This operator needs two expressions. Each expression should contain the value of one custom attribute. To get the values, you need the OperatorProcessAttribute. Apply this for expression1 and expression2. In our example, the custom attributes are strings - which must be indicated. Therefore, we need to use expression ValueString (even if the actual value used for the calculation is a number).
|
---|
Example Calculation Rule |
CODE
{
"type": "OperatorAddition",
"expression1": {
"type": "OperatorProcessAttribute",
"expression": {
"type": "ValueString",
"value": "CustomAttribute1"
}
},
"expression2": {
"type": "OperatorProcessAttribute",
"expression": {
"type": "ValueString",
"value": "CustomAttribute2"
}
}
}
|
---|
Subtracting two Values
Use Case | You want to subtract CustomAttribute2 from CustomAttribute1. |
---|
Description | To subtract two attributes, you need the OperatorSubtraction. This operator needs two expressions. Each expression should contain the value of one custom attribute. To get the values, you need the OperatorProcessAttribute. Apply this for expression1 and expression2. In our example, the custom values are strings - which must be indicated. Therefore, we need to use expression ValueString (even if the actual value used for the calculation is a number).
|
---|
Example Calculation Rule |
CODE
{
"type": "OperatorSubtraction",
"expression1": {
"type": "OperatorProcessAttribute",
"expression": {
"type": "ValueString",
"value": "CustomValue1"
}
},
"expression2": {
"type": "OperatorProcessAttribute",
"expression": {
"type": "ValueString",
"value": "CustomValue2"
}
}
}
|
---|