> For the complete documentation index, see [llms.txt](https://codifi-fdm.gitbook.io/codifi-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codifi-fdm.gitbook.io/codifi-docs/cross-platform-features/calculated-fields.md).

# Calculated Fields

Calculated fields let you define formulas in the Library that automatically compute a field's value, so users never need to enter it manually. They work the same way on the **web app** and the **mobile app**.

Common examples:

* **Total Cost** = Quantity × Unit Price
* **Area** = Length × Width
* **Completion %** = (Completed Items ÷ Total Items) × 100

***

## What Are Calculated Fields?

A calculated field is a field whose value is derived from a formula rather than direct user input. The formula references other fields in the same Record (or related Records) by their field ID. When the source values change, the calculated result updates automatically.

Calculated fields keep data consistent and reduce manual entry errors — especially useful for measurements, totals, and any value that follows a fixed rule.

***

## Configuring (Web)

Calculated fields are set up in the **Library** on the web app, where you build and manage your Compositions (templates).

1. Open the **Library** from the main navigation.
2. Select the **Composition** (template) you want to edit.
3. Navigate to the **Archetype** and open the **section** that should contain the field.
4. Add a new field or edit an existing one.
5. Set the **field type** (e.g., Number, Decimal).
6. Enter your **formula expression** in the formula input. Reference other fields using their field ID.
7. Save the field and publish the template.

Once saved, the formula is applied across all Projects using that template — no per-Project setup needed.

> **Looking for the full list of operators and patterns?** See the [Ripple section](/codifi-docs/cross-platform-features/ripple.md) — the [Value Formulas page](/codifi-docs/cross-platform-features/ripple/value-formulas.md) goes deep on math, text, date, and cross-Record lookup formulas, with examples.

> **Screenshot placeholder:** *The field editor in the Library, showing the formula input with an example expression such as `{length} * {width}`.*

### Runtime behavior on web

When users enter data on the web, calculated field values appear in Record detail views and data grids. Values update in real time as the referenced fields are edited — no save or page refresh required.

> **Screenshot placeholder:** *A Record detail view on web showing a calculated field (e.g., "Total Cost") updating automatically as Quantity and Unit Price are edited.*

***

## Using in the Field (Mobile)

On mobile, calculated fields are powered by the **Ripple formula engine**, which evaluates formulas locally on the device. This means:

* Formulas work fully **offline**, with no server connection needed.
* Results are computed immediately as field values change.
* When the device syncs, calculated results converge correctly across all users and devices.

Field crews recognize a calculated field by its **FX icon** — and by the fact that the value pre-fills or updates automatically as related fields change. Calculated fields are read-only in the field, so crews can't overwrite a formula-driven value by accident.

***

## Repeater Grid Sections

Calculated fields work correctly inside **repeater grid sections** (sections with multiple rows). Formulas resolve independently for each row, so a "Total" column calculates per-row values without any extra configuration.

## Cross-Record Calculations

Formulas can reference fields on **parent or child Records**, enabling cross-Record calculations. For example, a parent Record can display a rolled-up total derived from values across its child Records.

## Default Values Powered by Formulas

Formulas are not limited to computed display values — they can also power **default values** for new Records. When a Record is created, any formula-based defaults evaluate immediately and pre-populate the relevant fields, giving users a sensible starting point they can optionally override.

***

## Tips

* **Field references use the field's ID**, not its display name. You can find a field's ID in the Library when editing that field.
* **Circular dependencies** (e.g., Field A depends on Field B, which depends on Field A) are detected automatically and reported as a configuration error.
* **Null and empty fields** are handled safely — if a referenced field has no value, the formula treats it as zero (or an appropriate empty value) rather than throwing an error.
* Calculated fields are **read-only** for end users — the value is controlled entirely by the formula.
