# How values roll up to a parent

A parent item can show a figure for a field even when nobody typed one on it. The figure is calculated from the items below the parent. The field's **Rollup** setting, in the field's **Hierarchy** settings, decides how.

In a list, a calculated figure is shown in bold. Pointing at it shows a tooltip that explains how it was calculated.

## The functions

A number field, and a formula whose result is a number, can use these:

- **Sum**, the default: the values below added together.
- **Average**: the mean of the values below.
- **Min** or **Max**: the lowest or the highest value below.
- **None**: nothing is calculated. A parent shows only its own value.

A date field can use **Min**, **Max** or **None**. **Max** is the default.

## Tracked time always adds up

- Tracked time has no **Rollup** setting. A parent shows its own logged time plus all the time logged below it.
- A formula that only adds up tracked time works the same way and has no setting either. An example is `{Tracked Time (h)} * 50`.
- If an edit makes such a formula stop adding up tracked time, the setting chosen before applies again.

## A value typed on the parent wins

For a number or a formula, a value the parent holds itself replaces the figure from below. This is true for every function. A `0` counts as a value.

A date the parent holds itself also wins in its row. A parent with no date of its own shows the earliest or the latest date among the items below it, as **Min** or **Max** says.

## How an average is counted

An average counts every value below the parent once. It never takes an average of averages.

A child that holds its own value counts as one value. A child with no value of its own passes on the values below it.

## Group headers and the total row

A group header and the total row at the bottom of a list use the same function as the rows. An average there also counts every value once. Under **None**, both stay empty.

A view can choose its own function for a column under **Total**. The rows keep the field's function. [List view](../../views/list-view/) shows where to choose it.

- For a number column, a view's own **Sum**, **Average**, **Min** or **Max** reads the figures of the top-level rows. Each top-level row counts as one value.
- When the field's **Rollup** is **None**, each row shows only its own value. The view then reads the value of every item it shows.
- When the view chooses the field's own function, the totals do not change.
- For a date column, **Min** or **Max** shows the earliest or the latest date in the view, whatever the field's **Rollup** is.
- **Count non-empty** counts every item in the view that shows a value, including a figure calculated from the items below it. A value a parent passes down to its children is not counted on them. For tracked time, an item that shows no time is not counted.
- A total shows only the figure. Point at it to see which function made it, such as "Sum of all item values in this group."

Sorting uses the field's function too. A column sorts parents by the figure calculated with that function.

## A formula that uses ROLLUP

A formula can read the figure this page describes with `ROLLUP`, for example `{Budget} - ROLLUP({Spent})`. Here **Spent** is a number field of your own. The **Cost** field cannot be used, because a formula cannot read it. [Formula functions](../../types-and-fields/formula-functions/) lists what `ROLLUP` accepts.

- `ROLLUP` counts every item below, whatever the view shows. The view's filter, its types and its **Rollup** choice of **Filtered** or **All** do not change it.
- With **Filtered**, a list calculates a parent's cell only from the rows that the view shows. The cell and `ROLLUP` can therefore show different figures for the same item.
- Every screen shows the same `ROLLUP` figure for an item. The list, the board, the item page and a filter on the formula all agree.
- `ROLLUP` counts the items below that your role can read. Two people with different roles can see different figures.
- A formula that uses `ROLLUP` usually needs its own **Rollup** setting at **None**. Its figure already covers the items below, so a sum or an average of it in a group header means little.

## Example

A project has two tasks. Task A has the value 10. Task B has no value of its own, and its two child tasks have 20 and 30.

- **Sum**: Task B shows 50, and the project shows 60.
- **Average**: Task B shows 25. The project shows 20, the mean of 10, 20 and 30. It does not show 17.5, the mean of Task A's 10 and Task B's 25.
- **Min**: Task B shows 20, and the project shows 10.
- **None**: Task B and the project show nothing.

Under **Sum**, a formula `ROLLUP({Spent})` on the project shows 60, where **Spent** is the field above. A list view under **Filtered** that hides the child task with 30 shows 30 for the project. The formula on the project still shows 60.

## Things that may surprise you

- **An average of a ratio is a mean of ratios.** For a formula such as **Spent** divided by **Budget**, **Average** shows the mean of the children's ratios. It does not divide the total of **Spent** by the total budget. To divide the totals, write `ROLLUP({Spent}) / ROLLUP({Budget})`.

## Next

- [What is a field?](../../types-and-fields/what-is-a-field/)
- [Formula functions](../../types-and-fields/formula-functions/)
