How to write formulas for formula fields and Formula rules, how empty values, dates and text behave, which result type to pick and when values are recalculated.
A formula works out a value from other fields of the record, for example a total from quantity and price, or the number of days until a due date. You use formulas in Formula fields and in Formula rules. This page explains how to write them; the full list of functions is in Formula functions.
Where to find it
Formula field: Sidebar → Admin → Entity Manager, open the module (admin screens call modules "entities"), Fields tab, Add Field, TypeFormula. The Formula section has Expression and Result type.
Formula rule: the module's Rules tab, rule type Formula, with a Target Field (result goes here) and a Formula. See Rules.
Write a formula
You want
Write
A field's value
Its field name (not its label): quantity * unitPrice
A field of a linked record
Dots, up to 3 links deep: account.name, order.customer.country
Text
In single or double quotes: "Overdue", 'paid'
Yes, no, empty
TRUE, FALSE, NULL
A function
Its name and arguments; capitals don't matter: ROUND(total, 2)
Operators
Kind
Operators
Arithmetic
+-*/%
Comparison
=!=<>><>=<=
Logic
ANDORNOT, or &&||
Empty checks
IS NULL, IS NOT NULL
Lists
IN ("a", "b"), NOT IN (…)
Examples (also shown in the app's Function Reference):
quantity * unitPrice
IF(AND(status = "paid", amount > 0), amount, 0)
IF(dueDate IS NOT NULL AND dueDate < NOW(), "Overdue", "OK")
CONCAT(firstName, " ", lastName)
DATEDIFF(NOW(), createdAt, "days")
While you type, the box shows "Checking formula…", then "Formula is valid · result: …" or the error with its position ("at character N"). Click a function in Function Reference to insert it. You can also describe the formula in the AI box above the expression, for example "calculate total as quantity × unit price" or "days since created".
Empty values
Situation
Result
Arithmetic or a comparison with an empty value
Empty. price * quantity is empty when either is empty.
IF, AND, OR, NOT with an empty value
Empty counts as false.
Dividing by zero
Empty, with the warning "Division by zero (the result of that division is empty)".
SUM, AVG, MIN, MAX
Empty values are skipped.
A linked record that is missing
The related field reads as empty.
A field name that does not exist
Always empty, with a warning.
To use a fallback, wrap the value: COALESCE(discount, 0) or IFNULL(discount, 0).
Numbers, text and dates
Exact decimals.0.1 + 0.2 is 0.3. ROUND rounds half away from zero: ROUND(1.005, 2) is 1.01, ROUND(-2.5) is -3.
+ with text joins text. If either side is text that is not a number, + joins them. So dueDate + 7 does not add a week: it gives text such as 2026-01-017. Use DATEADD(dueDate, 7, "days").
Dates use the workspace time zone.TODAY() is today in your workspace's time zone. DATEDIFF in days counts calendar days and ignores the time of day.
Result type sets how the value is stored, sorted and filtered: Automatic, Number, Whole number, Currency, Text, Yes / No, Date or Date & time.
Automatic picks Number when the expression only does maths with number fields. A formula that is a single date or yes/no function (such as TODAY() or ISNULL(email)) gets a date or Yes / No type. Anything else becomes Text, including a comparison such as amount > 100: choose Yes / No for conditions, and Date or Date & time for date calculations.
You can change a formula's result type later. Every existing value is cleared and recalculated in the background.
When values are recalculated
When
What happens
A record is saved
Its formulas are recalculated.
You change the expression or result type
Every existing record is recalculated in the background ("Recalculating existing records"). Values appear as each batch finishes.
A linked record changes
Formulas that read its fields refresh shortly after.
The formula uses NOW() or TODAY()
The value is recalculated whenever a record is shown, but sorting and filtering use the value from the record's last save.
You click Recalculate formulas
Every formula field is recomputed for all existing records, for example after an import or a rollup change.
Recalculate formulas appears on the Fields tab when the module has stored formula fields. You see "Formula recalculation queued".
Test a formula
Under the expression, Test Formula tries the formula as typed, before you save: pick one of the latest records under Record, click Test and see the Result. For a rollup, Preview Value works the same way but only after the field is saved ("Save the field first — its value is computed by the server."). "No records found to test against. Create some records first." means the module is empty.
Formula rules
A Formula rule writes its result into its target field when the record is saved. It uses the same language, with one exception: FX() (currency conversion) works only in formula fields. Rules of type Set Value run before Formula rules; see Rule conditions, values and order.
Do it with AI Assist
AI Assist can work out a formula for you, on its own or against one record, so you can check it before you save it.
نفّذها باستخدام AI Assist
What does DATEDIFF(dueDate, TODAY(), "days") give for invoice INV-2026-0001?
Troubleshooting
Message or symptom
Why
What to do
The formula is always empty
A field it uses is empty, a name is misspelled, or it divides by zero.
Check the field names (not labels), and wrap values in COALESCE.
""…" is not a field of … — it always reads as empty"
The name is not a field, often a label used instead of the field name.