# Rollup

> Use a Rollup column to show values from linked records, such as an order total, a count of open jobs, or the latest reading. Always up to date.

A Rollup column shows information from the records a [Relation](/docs/columns/relation) links to. It can list their values, count them, or calculate a sum, average, minimum, or maximum. The result is calculated each time the record is shown, so it always reflects the linked records as they are right now. Nobody edits a rollup by hand.

## When to use it

Use a Rollup for numbers that should follow the related records:

- An order's total, from the amounts on its order lines.
- The number of open jobs for a customer.
- The most recent reading for a sensor.
- The customer's city shown on each order.

Pick a different type when:

- All the inputs are columns on the same record: use a [Formula](/docs/columns/formula).
- The value must be saved and then stay fixed, or comes from a lookup that isn't this relation: use a [computation rule](/docs/business-rules/computation).

## Settings

| Setting | What it does |
| --- | --- |
| **Link Column** | The Relation column on this table to follow. Your table needs a Relation before you can add a Rollup. |
| **Foreign Field** | The column on the linked table to read, such as Amount or Status. Formula columns can't be used here. |
| **Aggregation** | What to do with the values, when the relation links to several records. |

The **Aggregation** choices depend on the type of the **Foreign Field**:

| Aggregation | Works with |
| --- | --- |
| **Values (list all)** | Any column. Shows the values from every linked record. |
| **Count** | Any column. Counts the linked records. |
| **Sum** and **Average** | Number columns. |
| **Min** and **Max** | Number and Date columns. Use Max on a date to get the latest one. |

If the relation holds a single link, the rollup simply shows the value from that one linked record.

## Tips

- Be clear about the relation, the field, and the aggregation: "Order Total is the Sum of Amount through Order Lines".
- A rollup always shows the live value. If you also need a value that doesn't change after a certain moment, such as the total at the time of invoicing, keep both: a rollup for the live total, and a [Number](/docs/columns/number) column filled in by a [computation rule](/docs/business-rules/computation) or a [workflow](/docs/workflows) for the invoiced total.
- The same applies to prices on order lines. If a line must keep the price from the day it was ordered, store it in a Number column on the line rather than rolling it up from the product.
- A Rollup can't be used inside a [Formula](/docs/columns/formula) and can't be converted to another type.

---

Source: https://community.sapugo.app/docs/columns/rollup
