# Cumulated sum

The cumulated sum step enables you to calculate running totals based on a reference column, typically dates. It's valuable for understanding accumulation over time and visualizing progressive totals.

### Step parameters

* `Columns to cumulate` **tuples({column; string})\***: the value columns you want to compute the cumulated sum of, and for each one the name of the result column (by default it will be your original column name suffixed by `_CUMSUM`).
* `Reference column to sort (usually dates)`**column(string)**: the column that will be used to order rows in ascending order. Usually you will use a date column here (to compute a year-to-date result for exemple).
* `Group By` **(string)** **(optional)**: if you need to apply the cumulated sum computation by group of rows, you may specify here the columns to be used to constitute groups.

### Example

**Input**

<figure><img src="/files/UGKYXEJoQznoVKz1qANw" alt=""><figcaption><p>Compute - Cumulated sum input</p></figcaption></figure>

**Configuration**

```json
{
    "cumul_columns": [
        {"sales": "cumulative_sales"},
        {"quantity": "cumulative_quantity"}
    ],
    "ref_column": "sales",
    "group_by": []
}
```

**Output**

<figure><img src="/files/PkjTIMLu745a1sh9Cn7m" alt=""><figcaption><p>Compute - Cumulated sum output</p></figcaption></figure>


---

# Agent Instructions: 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:

```
GET https://docs-v3.toucantoco.com/data-management-in-datahub/datasets-in-toucan/preparing-data/overview-of-youprep-tm/compute/cumulated-sum.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
