> ## Documentation Index
> Fetch the complete documentation index at: https://docs.invoca.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cumulative Functions

> Cumulative formulas calculate the average, max, min, or sum of your data over time, or any other sequential data.

Cumulative formulas are aggregate formulas that let you calculate the average, max, min, or sum of your data accumulated over time — or over any other sequential data.

Each cumulative formula accepts a Measure and one or more optional attributes to group by (like region or department):

```text theme={null}
formula (Measure, [attribute, attribute, ...])
```

Only the Measure value is required. If you supply both a Measure and attributes, the formula returns the aggregate of the Measure accumulated by the attribute(s) in the order specified.

## The cumulative formulas

| Function             | Description                                                                | Example                                           |
| :------------------- | :------------------------------------------------------------------------- | :------------------------------------------------ |
| `cumulative_average` | Average of the Measure, accumulated by attribute(s) in the order specified | `cumulative_average (revenue, order date, state)` |
| `cumulative_max`     | Maximum of the Measure, accumulated by attribute(s) in the order specified | `cumulative_max (revenue, state)`                 |
| `cumulative_min`     | Minimum of the Measure, accumulated by attribute(s) in the order specified | `cumulative_min (revenue, campaign)`              |
| `cumulative_sum`     | Sum of the Measure, accumulated by attribute(s) in the order specified     | `cumulative_sum (revenue, order date)`            |

You may have attributes in your search that aren't part of the cumulative formula. The formula resets its results for different values of any attribute not included in it.

## Calculate a cumulative sum

1. Start a new search.
2. In the upper-right of the table, click the **more options** menu icon and select **Add formula**.
3. Enter the `cumulative_sum` formula, providing a Measure and one or more attributes.
4. Name the formula by clicking its title and typing a new name.
5. Click **Save**. The formula appears in the search bar and as its own table column. A headline box showing the cumulative sum for the entire table appears at the bottom — click it to toggle between aggregations.

## Where to go next

* [Moving functions](/s/article/moving-functions)
* [Flexible aggregation functions](/s/article/flexible-aggregation-functions)
* [Group aggregation functions](/s/article/group-aggregation-functions)
* [Filtered aggregation functions](/s/article/filtered-aggregation-functions)
