Mathematic expression – calculating with numbers¶
The mathematic expression calculates a formula such as (Price * Quantity) * 1.19. It is written
like a text expression – fixed text for operators and numbers, inserted values for the
operands – and the resulting text is then calculated.
1. At a glance¶
| Purpose | Calculates an arithmetic formula |
| Typical use | Totals, prices including tax, percentages, rounded values |
| Returns | Decimal number |
| Related | Text, Aggregate (sums over related records), Modify Value (rules MathRound, MathAppendFormula) |
2. Settings¶
The editor is the same as for the text expression, without the switch "Text" / "HTML":
| Setting | Meaning |
|---|---|
| "Content" | The formula. Operators, brackets and constant numbers are typed as text; fields and other values are inserted as chips ("Insert Expression" or right click). |
| List below the content | Every inserted value with its own expression setting |
Formula syntax¶
| Element | Notation |
|---|---|
| Basic arithmetic | + - * / |
| Remainder, power | % ^ |
| Brackets | ( ) |
| Decimal separator | . (a comma is not a decimal separator) |
| Functions | for example ROUND(x, 2), MIN(a, b), MAX(a, b), ABS(x), FLOOR(x), CEILING(x), SQRT(x) |
3. Behaviour¶
- All inserted values are evaluated and inserted into the formula as text.
- The complete text is calculated.
- The result is returned as a decimal number.
If the formula cannot be calculated, the expression does not return a number but the formula
text itself, for example ( * 3) * 1.19. A place that needs a number then converts this text to
0. The most common cause is an operand that is empty or not a number – an empty field inserts
nothing, and the formula becomes incomplete.
4. Examples¶
Price including VAT: ( + field "Net price" + * + field "Quantity" + ) * 1.19.
With 12.50 and 4, the result is 59.5.
Rounded to two decimals: ROUND( + field "Hours" + * + field "Hourly rate" + , 2).
Optional operand: If "Discount" can be empty, insert a Modify Value
expression instead of the field: input "Discount", rule Coalesce with the value 0. The formula
then stays complete.
5. Limitations¶
- An empty or non-numeric operand breaks the formula (section 3). Guard optional fields.
- Inserted values that are text containing a comma as decimal separator (
12,5) are not read as numbers.