> For the complete documentation index, see [llms.txt](https://docs.dinmo.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dinmo.io/models/computed-fields/formula-fields.md).

# Formula Fields

Formula fields create a new value by applying an operation to fields in the same model.

Use them when the value can be calculated from fields already available on the parent model. For example, you can combine numeric fields, calculate a date offset, or create a boolean condition.

## Use other computed fields

Formula fields can reference existing formula fields and label fields in the same model. This lets you build complex calculations in smaller, reusable steps.

To prevent circular references, DinMo excludes the current field and any field that depends on it from the field picker.

## Create a formula field

1. Choose the parent model where the field will be created.
2. Select the output type.
3. Build the formula with fields, operators, and values.
4. Preview the result, then save the field.

## Choose an output type

The fields and operators available in the builder depend on the selected output type.

| Output type      | Typical use cases                                                  |
| ---------------- | ------------------------------------------------------------------ |
| Number           | Revenue calculations, scores, ratios, or durations.                |
| String           | Add a fixed text value or combine text fields.                     |
| Date or datetime | Add or subtract a period, or calculate a difference between dates. |
| Boolean          | Create a true or false eligibility condition.                      |

## Formula examples

| Use case                 | Example                                                        |
| ------------------------ | -------------------------------------------------------------- |
| Predicted lifetime value | `current_revenue + predicted_additional_value`                 |
| Subscription end date    | `subscription_start_date + 12 months`                          |
| Time since last purchase | Number of days between `last_purchase_at` and the current date |
| Activation eligibility   | `email_opt_in AND is_active`                                   |

## Example: predicted lifetime value

A customer model contains the revenue already generated and a predicted additional value.

Create a numeric formula field:

`current_revenue + predicted_additional_value`

The resulting `predicted_lifetime_value` field can be used in segments or activation mappings.

## Good practices

* Choose a field name that describes the calculated result.
* Confirm that each input field has the expected data type.
* Preview the formula before saving it.
* Split a complex calculation into several fields when this makes the logic easier to maintain.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.dinmo.io/models/computed-fields/formula-fields.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
