# RUNNINGSUM
URL: https://docs.valsight.ai/runningsum/
Description: RUNNINGSUM calculates a cumulative total along the time axis, where each period's value equals the sum of all values from the first non-empty period up to and including the current period.
**Category:** [Rollforward & time series](/rollforward-time-series/)

## Overview

The **RUNNINGSUM** function **calculates a cumulative total along the time axis**.

Each period's value equals the sum of all values from the first non-empty period up to and including the current period.

Use this function when you want to track how values accumulate over time or as a helper function.

## Syntax

`RUNNINGSUM('Node')`

**Example usage:** `RUNNINGSUM('Profit')`

## Parameters

| Parameter | Description                                                                  | Type           | Required |
| --------- | ---------------------------------------------------------------------------- | -------------- | -------- |
| **Node**  | Input node, specified using the node name in single quotes (e.g. `'Profit'`) | Node reference | Yes      |

## Output shape

| Aspect            | Behavior                                                     |
| ----------------- | ------------------------------------------------------------ |
| Dimensionality    | Preserves the input shape                                    |
| Row count         | Same number of rows as the input node                        |
| Time range        | Each period accumulates all preceding values                 |
| Non-time behavior | Running sum is calculated independently for each combination |

## Watch out

* RUNNINGSUM requires a time dimension in the input node.
* The cumulative calculation follows the chronological order of the time hierarchy.
* Each combination of non-time dimensions is accumulated independently.
* Periods before the first non-empty value are omitted from the output.
* Missing values after the first non-empty period are treated as zero.

## Examples

### Basic cumulative total

**Input node:** `'Profit'`

| Year | Value |
| ---- | ----- |
| 2025 | 10    |
| 2026 | 20    |
| 2027 | 15    |

**Formula:** `RUNNINGSUM('Profit')`

| Year | Calculation  | Result |
| ---- | ------------ | ------ |
| 2025 | N/A          | 10     |
| 2026 | 10 + 20      | 30     |
| 2027 | 10 + 20 + 15 | 45     |

### Multi-dimensional input

When the node has additional dimensions (e.g. Region), the running sum is calculated independently for each dimensional combination.

**Input node:** `'Revenue'`

| Year | Region | Value |
| ---- | ------ | ----- |
| 2025 | EMEA   | 50    |
| 2026 | EMEA   | 60    |
| 2025 | APAC   | 30    |
| 2026 | APAC   | 40    |

**Formula:** `RUNNINGSUM('Revenue')`

| Year | Region | Calculation | Result |
| ---- | ------ | ----------- | ------ |
| 2025 | EMEA   | N/A         | 50     |
| 2026 | EMEA   | 50 + 60     | 110    |
| 2025 | APAC   | N/A         | 30     |
| 2026 | APAC   | 30 + 40     | 70     |

Each region accumulates its values independently over time.

### Behavior with gaps in the data

When the input has missing values for some time periods, RUNNINGSUM skips leading empty periods and treats later gaps as zero.

**Input node:** `'Payments'`

| Year | Value |
| ---- | ----- |
| 2024 | *N/A* |
| 2025 | 100   |
| 2026 | *N/A* |
| 2027 | 50    |

**Formula:** `RUNNINGSUM('Payments')`

| Year | Calculation  | Result |
| ---- | ------------ | ------ |
| 2025 | N/A          | 100    |
| 2026 | 100 + 0      | 100    |
| 2027 | 100 + 0 + 50 | 150    |

2024 is omitted from the output because it is a leading empty period. 2026 has no value, so it is treated as zero, the running total carries forward unchanged.

## Related

| Function                                        | When to use instead                                                           |
| ----------------------------------------------- | ----------------------------------------------------------------------------- |
| [YTD](/ytd/)                                    | When you need running totals that reset within each year.                     |
| [RUNNINGPROD](/runningprod/)                    | When you need cumulative multiplication along the time axis.                  |
| [MOVINGSUM](/movingsum/)                        | When you need a sum over a sliding window instead of from the start.          |
| [MOVINGAVG](/movingavg/)                        | When you need an average over a sliding window instead of a cumulative total. |
| [ROLLFORWARD\_ADVANCED](/rollforward-advanced/) | When you want to project values forward in time.                              |
