Reference Updated April 8, 2026

MOVINGSUM

Category: Rollforward & time series

Overview

The MOVINGSUM function returns the moving sum over the last WindowSize elements including the current one. If there are not enough preceding elements to fill the window, null is returned for those entries.

Use this function when you need a rolling sum over a defined time window.

Syntax

MOVINGSUM('Node', "TimeLevel", WindowSize)

Example usage: MOVINGSUM('Revenue', "Month", 12)

Parameters

ParameterDescriptionTypeRequired
NodeInput node, specified using the node name in single quotes (e.g.'Revenue')Node referenceYes
TimeLevelName of the time level that forms the time series to sum up (e.g."Month", "Quarter")Level nameYes
WindowSizeNumber of elements (including the current one) to sum up. Must be greater than 0.NumberYes

Output Shape

AspectBehavior
DimensionalitySame as input, but the time dimension is at the specified TimeLevel granularity. If the input is finer than the specified level, it is automatically rolled up.
Time rangeThe first (WindowSize - 1) entries are dropped because there are not enough preceding values to fill the window.
ValuesEach value is the sum of the current and the preceding (WindowSize - 1) entries along the time level.
Row countReduced by (WindowSize - 1) entries compared to the input.

Watch Out

  • The first (WindowSize - 1) entries are always null (dropped) because the window cannot be fully filled.
  • The input must have a time level. If the input has no time dimension, the function fails.
  • The input must be at least as fine-grained as the specified time level. For example, you cannot compute a moving sum on "Month" if the input only has "Year" data.
  • If the input is finer than the specified level (e.g. input is at "Month" but you specify "Quarter"), the data is automatically rolled up to the specified level before summing.

Examples

Two-period moving sum by quarter

This example shows a two-period moving sum across quarterly values. The result starts once enough values are available to fill the window.

Input node: Profit

QuarterProfit
2025-Q130
2025-Q2120
2025-Q3210
2025-Q4300

Formula: MOVINGSUM('Profit', "Quarter", 2)

Quarter→ MOVINGSUM Result
2025-Q2(30 + 120) = 150
2025-Q3(120 + 210) = 330
2025-Q4(210 + 300) = 510

2025-Q1 has no result because there is no preceding quarter to complete the two-element window.

Four-quarter rolling sum (trailing twelve months)

A common use case: summing the last 4 quarters to get a trailing twelve-month total.

Input node: Revenue

QuarterValue
2025-Q1100
2025-Q2120
2025-Q390
2025-Q4140
2026-Q1110
2026-Q2130

Formula: MOVINGSUM('Revenue', "Quarter", 4)

Quarter-> MOVINGSUM Result
2025-Q4100 + 120 + 90 + 140 = 450
2026-Q1120 + 90 + 140 + 110 = 460
2026-Q290 + 140 + 110 + 130 = 470

The first three quarters have no result because the four-element window cannot be filled.


FunctionWhen to use instead
MOVINGAVGWhen you need a rolling average over the same time window instead of a sum.
SHIFTWhen you need to shift values along a time level rather than aggregate them over a rolling window.
RUNNINGSUMWhen you need a cumulative sum from the start of the time series (no fixed window).
Was this page helpful?