# Calculate values with an Equation field

> Build a formula from a table's fields and functions, choose a Text, Number or Date result, and use IF statements to calculate a value for every record.

Source: https://tadabase.com/docs/data/equation  
Status: Verified Nov 17, 2026. Checked against the current product

An Equation field calculates a value for each record from that record's other fields, using functions such as `IF`, `CONCAT`, `DATEDIFF` and `ROUND`. Use it when a value should always follow from other fields, such as a total with a fee added, a label based on a status, or the number of days between two dates.

The result is saved with the record and updated when the record changes. Nobody can type a value into an Equation field: in forms it is shown read-only.

## Add an Equation field

1. **Open the table's fields** In the Data Builder, open the table and go to its **Fields** tab.
2. **Add the field** Click **Add New Field**. In the **Equation** group choose **Equation**, then click **Add and Configure**.
3. **Name it** Enter a **Name**, for example `Total With Fee`.
4. **Write the equation** Type the formula in the **Equation** box. Type `{` to pick a field, and start typing a function name to see matching functions. See [Write the equation](#write-the-equation).
5. **Choose the result type** Pick **Text**, **Number** or **Date** under **Output Type**.
6. **Save** Click **Save**. The builder runs the equation against the table before it saves, and shows an error instead if the database cannot run it.

![The Equation field settings with the Snippets button, the equation editor holding an IF formula and the Output Type menu](https://tadabase.com/docs-shots/data-equation-field-form.webp)

**Snippets** opens a library of ready-made equations. Click **Insert** on one to put it in the box, then replace its fields with your own.

## Write the equation

- Put field names in curly braces: `{Total Cost}`. The editor shows names, but saves the field's slug, so renaming a field later does not break the equation.
- Put text in quotes: `'Paid'`. Numbers need no quotes.
- Use `+`, `-`, `*` and `/` for math, and `=`, `<>`, `!=`, `>`, `<`, `>=`, `<=` to compare values.
- Write a function name followed by parentheses, with every argument inside them: `UPPER({Customer})`.
- Functions can be nested inside each other: `ROUND({Price} * {Quantity}, 2)`.

```text
{Price} * {Quantity}
CONCAT({First Name}, ' ', {Last Name})
DATEDIFF({Due Date}, {Start Date})
ROUND({Hours} * {Rate}, 2)
```

As you type, a line under the box checks the syntax. It shows **Valid Syntax!** when the equation is well formed, or a message such as **Unknown function name**, **Invalid field reference**, **Missing closing parenthesis )** or **Unclosed function**. Fix the message before you save.

Every function you can use is listed, with an example, in [Equation functions and examples](https://tadabase.com/docs/data/equation-functions).

> **Older screenshots:** Older versions of the editor had **Add Field**, **Math Function**, **Text Function** and **Date Function** menus and a **Validate Equation** button. The editor replaced them: you now type fields and functions straight into the box, and it checks the syntax as you type.

## Choose the output type

The output type decides how the result is stored and which conditions you get when you filter on the field (for example **contains** for text, or date conditions for a date).

| Output Type | Use it for | Extra settings |
| --- | --- | --- |
| **Text** | Labels, joined text, formatted values such as `$1,250.00` | None |
| **Number** | Totals, counts, differences between dates in days | **Decimal Places** (0 to 3), **Thousands Delimiter** (**None**, **Comma**, **Period**, **Space**) and **Disable Rounding** |
| **Date** | Due dates, renewal dates, any result that is a date | None |

With **Disable Rounding** on, the full-precision value is stored and used in calculations, and the display is cut to the number of decimal places instead of rounded.

> **Calculate in Real Time (beta):** This switch makes the database calculate the value as each record is saved. It only works for equations that use fields of the same table and do not use `NOW()`, `CURDATE()` or connected records; if an equation does not qualify, it stays a normal equation and the field explains why. Turning it on or off rebuilds the column, which can take a while on a large table.

## Use IF statements

`IF` returns one value when a condition is true and another when it is false. It takes three arguments separated by commas: the condition, the value if true, and the value if false.

```text
IF(condition, value_if_true, value_if_false)
```

For example, to add a $5 shipping fee to orders of $100 or less and leave larger orders as they are:

```text
IF({Total Cost} <= 100, {Total Cost} + 5, {Total Cost})
```

Each argument can be a field, a fixed value, a calculation or another function. This equation shows `Valid` when a customer's email address ends in `tadabase.io` and `Invalid` otherwise:

```text
IF(SUBSTRING_INDEX({Email}, '@', -1) = 'tadabase.io', 'Valid', 'Invalid')
```

**Check more than one condition.** Join conditions with `&&` (and) or `||` (or). This adds the fee only to orders from $100 up to, but not including, $200:

```text
IF({Total Cost} >= 100 && {Total Cost} < 200, {Total Cost} + 5, {Total Cost})
```

**Several outcomes (else if).** Put the next `IF` in the false argument of the one before. Each nested `IF` works like any other:

```text
IF({Score} >= 90, 'A', IF({Score} >= 80, 'B', IF({Score} >= 70, 'C', 'Below C')))
```

## Troubleshoot IF statements

A long nested `IF` is easier to fix when you build it one level at a time.

1. **Write each condition on its own** Put a placeholder text in the false argument and check that the syntax line shows **Valid Syntax!**.
2. **Nest the next level** Replace the placeholder with the next `IF`, again ending in a placeholder. Check it, then save and look at a few records.
3. **Repeat** Add one level at a time until the last `IF` has its real false value.

```text
IF({# of Managers} = 2, {Store Quarterly Bonus} * 0.50, 'next')

IF({# of Managers} = 2, {Store Quarterly Bonus} * 0.50,
  IF({# of Managers} = 1 && {Position} = 'Manager', {Store Quarterly Bonus} * 0.70, 'next'))

IF({# of Managers} = 2, {Store Quarterly Bonus} * 0.50,
  IF({# of Managers} = 1 && {Position} = 'Manager', {Store Quarterly Bonus} * 0.70,
    IF({# of Managers} = 1 && {Position} = 'Assistant Manager', {Store Quarterly Bonus} * 0.30, 0)))
```

If the builder will not save, read the message it shows. A message such as `Invalid ROUND() usage — please check the ROUND() signature.` means a function got the wrong number or kind of arguments; check it in [Equation functions and examples](https://tadabase.com/docs/data/equation-functions). Check also that the true and false values fit the **Output Type**: a Number equation should return numbers in both branches.

## Fields you can use, and connected records

Type `{` to see the fields an equation can read. The list holds the fields of the same table. Some field types appear as parts:

- **Person Name**: `- Title`, `- First Name`, `- Middle Name`, `- Last Name`.
- **Address**: `- Address`, `- Address 2`, `- City`, `- State`, `- Country`, `- Zip`, `- Latitude`, `- Longitude`.
- **Date Range**: `- Start Date`, `- End Date`, `- All Day`.
- The record ID, also as `- Encoded` for the encoded ID used in links and the API.

Connection fields, Checkbox, Multi-Select, Attachments, File, Image and Signature fields are not in the list.

An equation cannot read fields of connected records directly. To use one, first bring the value into this table with a [Rollup field](https://tadabase.com/docs/data/rollup) (for example the sum, count or latest value of the connected records), then use the Rollup in your equation. See also [Which fields can be used in equations and formulas](https://tadabase.com/docs/data/which-fields-are-referenceable-in-equations-and-formulas).

## Limits

- An Equation field's value is always calculated. You cannot type it in a form or set it yourself.
- Only the functions in [Equation functions and examples](https://tadabase.com/docs/data/equation-functions) are accepted.
- Equations cannot contain `;`, `@`, `#` or comments, or words such as `SELECT`, `UPDATE` or `DELETE`. They calculate a value from the current record only.
- `NOW()`, `CURDATE()` and `CURTIME()` return the app's current date and time at the moment the record is calculated. The stored value does not change by itself as time passes; it updates when the record is calculated again.

To show a calculated value without storing it, for example to update a total live while someone fills in a form, use a [Dynamic field](https://tadabase.com/docs/data/dynamic-field) instead.
