Formulas
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.
- Who can use this
- Account owner, Manager
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.
| 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 | AND OR NOT, 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".
| 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).
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").TODAY() is today in your workspace's time zone. DATEDIFF in days counts calendar days and ignores the time of day.DATEADD("2026-01-31", 1, "months") gives 28 February.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 | 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".
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.
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.
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.
Do it with AI Assist
| 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. | Use the field's name. |
| "Unknown function …()" | The function does not exist. | Use one from Formula functions. |
| "…() takes 1–2 arguments, got 3" | Wrong number of arguments. | Check the function's syntax. |
| "Unterminated string literal", "Unexpected character "#"", "Missing ")"", "Unexpected end of formula", "Expected NULL after IS" | A syntax mistake. | Close quotes and brackets; write IS NULL or IS NOT NULL. |
| "Formula is empty", "…longer than 4096 characters", "Formula is nested too deeply", "Formula result is too large" | The formula is empty, too long or too complex. | Simplify it, or split it over several formula fields. |
| "Formula cannot be evaluated: …" | Saving found an error. | Fix the error named after the colon. |
| "Formula "…" creates a circular reference: …" | The formula refers back to itself through other fields. | Break the loop. |
| "Field "…" creates a circular dependency across entities: …" | Formulas or rollups in different modules depend on each other in a loop. | Break the loop. |
| "Nothing to recalculate" / "This entity has no records yet." | The module has no records. | Nothing to do. |
| "The recalculation could not be queued. Try again in a moment." | It could not start. | Try again in a moment. |
A TODAY() formula sorts on an old value | Sorting uses the value saved with the record. | Save the records, or click Recalculate formulas. |