Simple conditions, calculations and field commands – how can I calculate fields automatically and automate processes?
Before you start: This article is aimed at advanced users who already understand the basic principles of formulas, calculations and operators. If you're not familiar with these basics yet, we recommend first reading the articles How do formulas work in Vaira? and Operators for calculations and automations in Vaira Office so you can follow the content here more easily.
What are simple conditions, calculations and field commands?
Vaira lets you use the benefits of digitalization so that you no longer have to do routine calculations yourself and can automate your workflows.
Calculations
For calculations, this means: if your construction documentation has fields that always depend on each other, you can link them mathematically. For example, if you have a "quantity" field, a "price" field and a "total cost" field for components, you'd otherwise do the multiplication yourself for every job. Instead of working out 13 pcs × €7.53 yourself, you can set up Vaira so that the "total cost" field automatically calculates "quantity" × "price". In the same way, you can of course combine lots of fields and let Vaira do the math.
Simple conditions
Vaira also helps you improve the quality of your documentation and automate your processes. You can improve quality with plausibility checks, for example. For a field, you can define the range the entered value must fall within – to catch transposed digits, among other things.
A simple example: if a user has to enter the day's temperature, you can set -35 °C to 50 °C as the range of valid values. If the user accidentally enters 71 °C instead of 17 °C, Vaira lets them know right away that the value is outside the valid range, so they can correct it immediately.
You can also use conditions for process automation, for example, to build more complex processes. By default, completing a step in your process starts all connected steps. With conditions, however, you can specify that after step 1, step 2 should only start if field A contains the value X, and that step 3 should start otherwise.
Useful calculations, conditions and commands for everyday work – overview
Below are some examples of calculations, conditions and field commands that may come in handy in your work. Vaira offers many more commands – listing them all here would be far too much. If you're ever missing a command, just ask us whether and how it can be done in Vaira. We aim to add more useful commands to this list over time.
Below the cheat sheets for each category, we explain each command in detail.
Passing on, taking over and syncing values
| Name | Command | Use |
| Passing on values |
Reference 2 sends, reference 1 receives. |
Automatically passes the value in the field of Verweis2 (reference 2) to the field of Verweis1 (reference 1). This saves you from entering the same data several times when different fields in a process always contain the same information. |
Calculating
| Name | Command | Use |
| Calculating with dates |
|
Calculates the value of a date field by adding or subtracting a specific period of time (days, weeks). |
| Calculating with timestamps |
|
Calculates the value of a timestamp field by adding or subtracting a specific period of time (seconds, minutes, hours, days, weeks). |
| Number of measurements | size(...) |
Calculates the number of measurements in a field and returns the value. Can also be used as a condition. |
Conditions
| Name | Command | Use |
| Either ... or ... | (...) || (...) |
Checks two or more values to see whether one of the conditions is met. |
| Both ... and ... | (...) && (...) |
Checks two or more values to see whether all conditions are met. |
| If ... is not the case | !(...) |
Negates the value in the brackets; e.g. !(Hammer) means: if it is not Hammer. |
| Combined conditions | ((...) && (...)) || ((!(...)) || (...))) |
Conditions and negations can also be combined and nested to build complex conditions. |
| Status of a step as a condition | (...) == "..." |
Checks whether a step has a specific status and returns true or false. |
| Number of measurements as a condition | size(...) > 0 |
Checks the number of measurements in a field and returns true or false based on the condition. |
| Number of selected options in a selection field as a condition | size(...) > 0 |
Checks the number of selected options in a selection field and returns true or false based on the condition. |
| Occurrence in a list as a condition | ("..." in (...)) |
Checks whether a specific text or string occurs in a list field; if so, it returns true, if not, false. |
Useful commands for everyday work – detailed explanations
Passing on values
Use case
Your process has fields that basically contain the same values (such as an address field) but appear in different process steps. So that each field doesn't have to be filled in again, you can pass the value from the first field to all other fields of the same kind. That keeps the content of the fields in sync.
General structure
Verweis1:Verweis2
Example
tasks.bautagebuch.fields.Baudienstleister:tasks.aufmass.fields.Baudienstleister
- Receiving field
the first reference before the:receives the value of the second reference; here, the field "Baudienstleister" (construction contractor) in the task "Bautagebuch" (construction diary) receives the value (tasks.bautagebuch.fields.Baudienstleister), - Operator
followed by the operator:, - Sending field
and then the sending field is defined, which here is the field "Baudienstleister" in the task "Aufmass" (site measurement) (tasks.aufmass.fields.Baudienstleister). - Result
If "Tiefbau GmbH" is entered in the sending field, for example, the content of the receiving field also becomes "Tiefbau GmbH". - Example result
Tiefbau GmbH
Calculating with dates
Use case
You have a date field whose date should be calculated from the date in another field. You can add and subtract dates. You can use fixed values in the formula as well as dynamic calculations based on other field values.
General structure
Addition: ... + "x"
Subtraction: ... - "x"
Example
The field tasks.Stammdaten.fields.Projektfrist contains the formula
tasks.Stammdaten.fields.Startdatum + tasks.Stammdaten.fields.Dauer
- Field for the calculation
You enter the formula in the field that should show the result of the calculation; here, the field "Projektfrist" (project deadline) in the task "Stammdaten" (master data) receives the value (tasks.Stammdaten.fields.Projektfrist), - The original date
...
first, you enter the field with the date using the familiar field reference; here, the value from the field "Startdatum" (start date) in the task "Stammdaten" is used (tasks.Stammdaten.fields.Startdatum), - The operator
+
then specifies whether it's an addition or a subtraction (+), - The value for the calculation
and finally, you use a fixed number or – as in this example – a field value for the calculation; in this case, the value from the field "Dauer" (duration) in the task "Stammdaten" (tasks.Stammdaten.fields.Dauer). - So what exactly happens here?
In the example, the value of the field "Startdatum" plus the value from the field "Dauer" is used to show the result in the field "Projektfrist". - Which values can I use for calculations?
You can use both days and weeks. You can do this in the formula or dynamically via fields, if they're text fields. The time is given as abbreviations of the units:dfor days andwfor weeks.- For days, enter the value with a
deither in the formula or in the text field, for example:tasks.Stammdaten.fields.Startdatum + "13d". This adds 13 days to the start date. Alternatively, you can write the time span without quotation marks in the fieldtasks.Stammdaten.fields.Dauer, i.e.13din the field. - For weeks, enter the value with a
weither in the formula or in the text field, for example:tasks.Stammdaten.fields.Startdatum + "2w". This adds 2 weeks to the start date. Alternatively, you can write the time span without quotation marks in the fieldtasks.Stammdaten.fields.Dauer, i.e.2win the field. - Combinations of several units are also possible. To do this, enter the combined values together either in the formula or in the text field, for example:
tasks.Stammdaten.fields.Startdatum + "2w3d". This adds 2 weeks and three days to the start date. Alternatively, you can write the time span without quotation marks in the fieldtasks.Stammdaten.fields.Dauer, i.e.2w3din the field.
- For days, enter the value with a
- Example result
04/27/2024
Calculating with timestamps
Use case
You have a timestamp field whose date and time should be calculated from the date and time in another field. You can add and subtract dates and times. You can use fixed values in the formula as well as dynamic calculations based on other field values.
General structure
Addition: ... + "x"
Subtraction: ... - "x"
Example
The field tasks.Leistung.fields.Arbeitsdauer contains the formula
tasks.Leistung.fields.Arbeitsende - tasks.Leistung.fields.Arbeitsbeginn
- Field for the calculation
You enter the formula in the field that should show the result of the calculation; here, the field "Arbeitsdauer" (working time) in the task "Leistung" (work performed) receives the value (tasks.Leistung.fields.Arbeitsdauer), - The original date and time
...
first, you enter the field with the date and time using the familiar field reference; here, the value from the field "Arbeitsende" (end of work) in the task "Leistung" is used (tasks.Leistung.fields.Arbeitsende), - The operator
-
then specifies whether it's an addition or a subtraction (-), - The value for the calculation
and finally, you use a fixed number or – as in this example – a field value for the calculation; in this case, the value from the field "Arbeitsbeginn" (start of work) in the task "Leistung" (tasks.Leistung.fields.Arbeitsbeginn). - So what exactly happens here?
In the example, the value of the field "Arbeitsbeginn" is subtracted from the value in the field "Arbeitsende" to show the result in the field "Arbeitsdauer". - Which values can I use for calculations?
For timestamp fields, you can use seconds, minutes and hours for the time as well as days and weeks for the date. You can do this in the formula or dynamically via fields, if they're text fields. The time is given as abbreviations of the units:sfor seconds,mfor minutes,hfor hours,dfor days andwfor weeks.- For seconds, enter the value with an
seither in the formula or in the text field, for example:tasks.Leistung.fields.Arbeitsbeginn + "11s". This adds 11 seconds to the time in the timestamp field. Alternatively, you can write the time span without quotation marks in the fieldtasks.Leistung.fields.Arbeitsbeginn, i.e.11sin the field, to do the calculation. - For minutes, enter the value with an
meither in the formula or in the text field, for example:tasks.Leistung.fields.Arbeitsbeginn + "24m". This adds 24 minutes to the time in the timestamp field. Alternatively, you can write the time span without quotation marks in the fieldtasks.Leistung.fields.Arbeitsbeginn, i.e.24min the field, to do the calculation. - For hours, enter the value with an
heither in the formula or in the text field, for example:tasks.Leistung.fields.Arbeitsbeginn + "3h". This adds 3 hours to the time in the timestamp field. Alternatively, you can write the time span without quotation marks in the fieldtasks.Leistung.fields.Arbeitsbeginn, i.e.3hin the field, to do the calculation. - For days, enter the value with a
deither in the formula or in the text field, for example:tasks.Leistung.fields.Arbeitsbeginn + "13d". This adds 13 days to the start date. Alternatively, you can write the time span without quotation marks in the fieldtasks.Leistung.fields.Arbeitsbeginn, i.e.13din the field. - For weeks, enter the value with a
weither in the formula or in the text field, for example:tasks.Leistung.fields.Arbeitsbeginn + "2w". This adds 2 weeks to the start date. Alternatively, you can write the time span without quotation marks in the fieldtasks.Leistung.fields.Arbeitsbeginn, i.e.2win the field. - Combinations of several units are also possible. To do this, enter the combined values together either in the formula or in the text field, for example:
tasks.Leistung.fields.Arbeitsbeginn + "2w3d2h1m4s". This adds two weeks, three days, two hours, one minute and four seconds to the start date. Alternatively, you can write the time span without quotation marks in the fieldtasks.Stammdaten.fields.Dauer, i.e.2w3d2h1m4sin the field.
- For seconds, enter the value with an
- Example result
04/27/2024, 1:54:03 PM
Number of measurements
Use case
You want a field to show how many measurements have been taken in a measurement field.
General structure
size(...)
Example
The field tasks.Uebersicht.fields.Vermessungsanzahl contains the formula
size(tasks.Vermessung.fields.Vermessung).
- Command for the calculation
size
The commandsizebefore the brackets starts the count, - Field for the calculation
you enter the formula in the field that should show the result of the calculation; here, the field "Vermessungsanzahl" (number of measurements) in the task "Uebersicht" (overview) receives the value (tasks.Uebersicht.fields.Vermessungsanzahl), - The reference to the measurement field
...
inside the brackets, you then enter the field whose measurements should be counted; in this case, the measurements in the field "Vermessung" (measurement) in the task "Vermessung" (tasks.Vermessungen.fields.Vermessung), - So what exactly happens here?
In the example, we assume that a total of 5 measurements have been taken in the field "Vermessung". The formula counts them and automatically enters the value "5" in the field "Vermessungsanzahl".
- Example result
5
Either ... or ...
Use case
You have steps in a process or fields that should only run or matter if one of several conditions is met. You can also add a plausibility check to field values that cover a range of known options, to give the user feedback or more options when certain cases occur.
General structure
(...) || (...)
Example
A work step should check whether a job was completed successfully. If a working time of "0" or the status "abgebrochen" (canceled) was documented, the job is considered not properly completed. In this case, a special next step in the process should be triggered – for example, a root cause analysis – that wouldn't otherwise be activated.
tasks.Leistung.fields.Arbeitszeit == 0 || tasks.Leistung.fields.Status == "abgebrochen"
- Condition 1
Either the value in the field "Arbeitszeit" (working time) in the step "Leistung" (tasks.Leistung.fields.Arbeitszeit)must equal zero== 0, - Operator
or|| - Condition 2
the field "Status" in the step "Leistung" (tasks.Leistung.fields.Status)must contain the value "abgebrochen" (== "abgebrochen"). - Result
If the field "Arbeitszeit" contains a zero or the field "Status" contains the value "abgebrochen", this condition is met and true is returned; otherwise, false is returned. This can affect how a process continues in different ways. - Example result
true
Both ... and ...
Use case
You have steps in a process or fields that should only run or matter if several conditions are met at the same time. You can also add a plausibility check to field values that cover a range of known options, to give the user feedback or more options when certain cases occur.
General structure
(...) && (...)
Example
A work step should check whether documentation was completed successfully. For this, the working time must be greater than zero and the status must be documented as "abgeschlossen" (completed). In this case, a special next step in the process should be triggered that wouldn't otherwise be activated.
tasks.Leistung.fields.Arbeitszeit > 0 && tasks.Leistung.fields.Status == "abgeschlossen"
- Condition 1
Both the value in the field "Arbeitszeit" in the step "Leistung" (tasks.Leistung.fields.Arbeitszeit)must be greater than zero> 0, - Operator
and&& - Condition 2
the field "Status" in the step "Leistung" (tasks.Leistung.fields.Status)must contain the value "abgeschlossen" (== "abgeschlossen"). - Result
If the field "Arbeitszeit" contains a number greater than zero and the field "Status" contains the value "abgeschlossen", this condition is met and true is returned; otherwise, false is returned. This can affect how a process continues in different ways. - Example result
true
If ... is not the case
Use case
A step should only be triggered if a certain value is not the specified value. Or a field should only be shown if another field hasn't been filled in.
General structure
!(...)
Example
A work step should check whether working time was documented, i.e. whether the field "Arbeitszeit" contains a value other than zero.
!(tasks.Leistung.fields.Arbeitszeit == 0)
- Operator
The negation operator comes before the bracket!(, - Referenced field value
the value in the field "Arbeitszeit" in the step "Leistung" (tasks.Leistung.fields.Arbeitszeit) must not equal zero ("== 0", but negated by the operator). - Result
If the field "Arbeitszeit" contains a value other than zero, the condition is met and true is returned; otherwise, false is returned. - Example result
true
Combined conditions
Use case
Lots of possible use cases whenever your automations need to be more complex.
General structure
You can combine as many different conditions as you like, in any way you like.
((...) && (...)) || ((!(...)) || (...)))
Example
((tasks.Leistung.fields.Arbeitszeit > 0 && tasks.Leistung.fields.Status == "abgeschlossen")) || ((!(tasks.Vermessung.fields.Status == "verworfen")) || (tasks.Vermessung.fields.Unterschrift == "")))
- Condition 1a
Both the value in the field "Arbeitszeit" in the step "Leistung" (tasks.Leistung.fields.Arbeitszeit)must be greater than zero> 0, - Operator
and&& - Condition 1b
the field "Status" in the step "Leistung" (tasks.Leistung.fields.Status)must contain the value "abgeschlossen" (== "abgeschlossen"), - Operator
or|| - Condition 2a
the field "Status" in the step "Vermessung" does not contain "verworfen" (discarded) - Operator
or|| - Condition 2b
the field "Unterschrift" (signature) in the step "Vermessung" is empty. - Result
If conditions 1a and 1b are both met, or if condition 2a or 2b is met, the whole combination of conditions is considered met and returns true; in all other cases, it returns false. - Example result
true
Status of a step as a condition
Use case
You want to enter a value in another field, run a calculation or something similar, depending on the status of a step.
General structure
(...) == "..."
Example
steps.Vermessung == "started"
- Reference to the step
(...)
First, you specify which step should be checked (steps.Vermessung), - Operator
==
next, you enter one of the familiar mathematical operators that suits your condition; in the example, we use "equals" (==), - The condition status
"..."
after the operator, you write the status the step must have for the condition to be met, in double quotation marks; in the example, we use "started".
- Possible statuses for your steps are
pending(not started yet) andstarted(currently in progress but not yet completed). When you complete the step, it goes into the transitional statuscompletingand then automatically takes on the statuscompleted.
- Possible statuses for your steps are
- So what exactly happens here?
In the example, Vaira checks whether the step "Vermessung" has already been started. Vaira then returns true or false. - Example result
true
Number of measurements as a condition
Use case
You want to create a condition that's only true if a certain number of measurements in a measurement field has been reached, hasn't been exceeded, or matches exactly.
General structure
size(...) > 0
Example
size(tasks.Vermessungen.fields.Vermessung) > 0
- Command for the calculation
size
The commandsizebefore the brackets starts the count, - The reference to the measurement field
(...)
inside the brackets, you then enter the field whose measurements should be counted; in this case, the measurements in the field "Vermessung" in the task "Vermessungen" (tasks.Vermessungen.fields.Vermessung), - The operator
>
here you can choose one of the familiar mathematical operators that suits your condition; in the example, we use "greater than" (>), - The condition value
0
and finally, you specify the specific value; here, "0". Of course, you can also put other field references here, for example to compare the number of measurements in two different measurement fields. - So what exactly happens here?
In the example, the number of measurements in the field "Vermessung" in the step "Vermessungen" is counted. Vaira then compares the value with the condition and returns true or false. - Example result
true
Number of selected options in a selection field as a condition
Use case
You want to create a condition that's only true if a certain number of options has been selected in a selection field.
General structure
size(...) > 0
Example
size(tasks.Bauteildokumentation.fields.Bauteile) > 0
- Command for the calculation
size
The commandsizebefore the brackets starts the count, - The reference to the selection field
(...)
inside the brackets, you then enter the field whose selections should be counted; in this case, the components in the field "Bauteile" (components) in the task "Bauteildokumentation" (component documentation) (tasks.Bauteildokumentation.fields.Bauteile), - The operator
>
here you can choose one of the familiar mathematical operators that suits your condition; in the example, we use "greater than" (>), - The condition value
0
and finally, you specify the specific value; here, "0". Of course, you can also put other field references here, for example to compare the number of selected options in two different selection fields. - So what exactly happens here?
In the example, the number of selected options in the field "Bauteile" in the step "Bauteildokumentation" is counted. Vaira then compares the value with the condition and returns true or false. - Example result
true
Occurrence in a list as a condition
Use case
You want to create a condition that's only met if a specific entry (word, string, number, selection, ...) has been selected in a list field or occurs in it.
General structure
("..." in (...))
Example
("Muffe" in tasks.Dokumentation.fields.Bauteile)
- Value to check for
"..."
word, number or string in double quotation marks"Muffe"(sleeve), - Operator
in
keyword that tells Vaira this is a list check and introduces the reference to the specific field, - The reference to the selection field
(...)
here you insert the specific field that should be checked for the search term (tasks.Bauteildokumentation.fields.Bauteile), - So what exactly happens here?
In the example, Vaira checks whether the term "Muffe" has been selected in the selection field "Bauteile" in the step "Bauteildokumentation". If so, the condition is met and Vaira returns true; if not, false. - Example result
true