Calculated fields: values that calculate themselves
A calculated field is not filled in manually. Its value is the result of a formula that reads other fields. You can use it for totals, VAT-inclusive amounts, discounts, differences between dates, or labels built from multiple values.
The calculation always runs on the server. The browser displays the result and the preview, but does not recalculate anything. What you see saved is exactly what the server computed using the same rules applied during saving.
Writing the formula
You build formulas using field tokens. The configurator lets you insert a reference to a field (@{…}) instead of typing its identifier by hand. Not all fields can be referenced: attachments, progressives, and other calculated fields are excluded. A calculated field depending on another calculated field would make the chain difficult to read and fix.
Operators
- Arithmetic:
+,-,*,/ - Comparisons:
=,!=,<,<=,>,>=(at most one per formula) - Parentheses and unary sign (
-)
Functions
| Function | What it does |
|---|---|
ROUND(value, digits) |
Rounds to a number of digits from 0 to 8 |
IF(condition, then, otherwise) |
Chooses a branch; evaluates only the chosen one |
SUM(a, b, …) |
Sums several values |
DAYS_BETWEEN(date1, date2) |
Days between two dates |
Write texts in quotes ("High") and numbers as numbers. The value null represents the absence of a value.
The result type
You do not choose whether the result is a number, a text, a boolean, or a date. The server infers it from the formula and displays it in the configurator. A calculated field that sums amounts is a number; one that concatenates texts is a text; a comparison results in a yes/no. For numeric results, you can choose the precision.
This prevents a common contradiction: a formula that produces text but is declared as a number, which would fail to save.
Type rules in practice
+is numeric only if all addends are numeric. Otherwise it concatenates:@{first_name} + " " + @{last_name}produces the full name, and"007" + 1produces"0071"because"007"is text. A text field stays as it was written.-,*,/require numbers. Strings that represent integers are read as numbers. A non-numeric text causes an error, not a zero.- Dates behave as dates: a date plus a number shifts by that many days, and a date minus a date gives the difference in days. Adding two dates concatenates their ISO forms.
- Percentages are worth the fraction: a percentage field with
22(22%) in a formula is worth0.22. Therefore,@{price} * (1 + @{vat})applies VAT correctly without dividing by hand. - Empty stays empty. If a referenced field is not filled in, the result is "Missing data", not zero. Zero is a value someone chose; absence is not.
Useful examples
Total with VAT
ROUND(@{taxable} * (1 + @{rate}), 2)
with @{rate} a percentage field (22 = 22%).
Discount
ROUND(@{price} - (@{price} * @{discount}), 2)
Label
IF(@{quantity} > 10, "Large order", "Small order")
Days to due date
DAYS_BETWEEN(@{due_date}, @{reference_date})
Preview, saving, and recalculation
The editor validates the formula with the server and shows the preview result. If the formula is invalid, if the preview is in progress, or if it fails, saving remains blocked. You cannot save a formula whose result you do not know.
Once saved, the field recalculates when a field it depends on changes. Already started instances are not recalculated until a dependency changes. This is intentional, because a calculation must not rewrite historical data on its own.
Limits and security
The grammar is closed: there is no arbitrary code and no access to the database or the browser. There are limits on expression length, number of references, and formula depth. Exceeding them results in an explicit error, not a silent truncation.
Common errors
| Message | What it means |
|---|---|
| Invalid formula | There is a syntax error or a reference that does not exist |
| Incompatible type | You are adding text and a number, or using a date where a number is needed |
| Division by zero | The divisor is zero: often an empty field used as a divisor |
| Missing data | A dependency is not filled in: the result stays empty |
The golden rule: write the formula thinking about the types of the fields you touch, not only about the result you want to obtain.
Key points
- A calculated field is not filled in: its value is the result of a formula that reads other fields.
- The calculation is always done by the server; the browser only shows the result and the preview.
- The result type (number, text, boolean, date) is inferred from the formula, not chosen by hand.
- Empty stays empty: an unfilled dependency gives "Missing data", not zero.
- The grammar is closed: no arbitrary code, no access to the database or the browser.
Calculate totals, amounts, and dates directly in your processes, without writing code: flowenti.com