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

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

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

Calculate totals, amounts, and dates directly in your processes, without writing code: flowenti.com