Documentation › Calculated variables
Calculated variables: a value that works itself out
A calculated variable has no typed value: a formula calculates it from other variables. For example Full name = first name and last name, or Budget left = total budget − budget spent.
What they are for
- The value is calculated again every time it is read with the current values of the other variables: when one changes, the result follows.
- It is read-only: no outcome (Outcomes) or answer to a question can write it, and it cannot be changed when an instance starts.
- The result is a text or a number.
Create one
- Open the start block of the process (or artifact), Variables tab, then Add variable.
- Choose the Calculated scope, give a name and choose the type of the result.
- Write the formula. A message under the box says what is wrong, or the type of the result. While a formula is wrong, Save stays disabled.
Write a formula
{{Name}}is a variable (the name is written as it is, with its spaces and accents).- Text is written between quotes:
' '. For a quote inside the text, double it:'it''s'. - The operators
+ - * /and the parentheses work on numbers only. To join text, useCONCAT:CONCAT({{FirstName}}, ' ', {{LastName}}). - An empty number counts as 0; an impossible calculation (division by zero, text that is not a number) gives no value.
- A calculated variable can use another one, but never itself (directly or through others).
Auto-completion: type {{ to see the variables, or the first letters of a function to complete it. Use the arrows, Enter or Tab to choose, Esc to close.
The functions
| Function | What it does |
|---|---|
CONCAT(a, b, …) | Joins text and values. |
UPPER(t), LOWER(t), TRIM(t) | Upper case, lower case, removes the spaces around. |
LEN(t) | Number of characters. |
ROUND(n, decimals) | Rounds (0 decimals when omitted). |
MIN(…), MAX(…), ABS(n) | Smallest, largest, absolute value. |
Where they are used
- In the Parameters tab of a process instance, with the Calculated scope.
- In the choices (conditions) and the repetitions of a phase.
- In document templates:
{{Budget_left}}takes the value calculated when the document is generated.