Skip to content

RollingSum

Time intelligence

RollingSum(expr, n, grain)

A rolling window of n grain-periods ("day" | "week" | "month" | "quarter" | "year") ending at each bucket. Missing periods count as zero, not skipped — the window runs over a gap-complete series of buckets, so a month with no sales still advances the window. Additivity rules match YTD (SQX015).

  • Smoothing seasonality: trailing-12-month revenue is the way to see trend through year-end spikes.
  • Trailing activity windows — orders in the last 4 weeks, signups in the last 90 days.
Revenue12mRolling := RollingSum([Revenue], 12, "month")

The measure’s history computes once in a values CTE; a range self-join then sums each bucket’s trailing window — gap-correct by construction:

// On a line chart by month
Revenue12mRolling := RollingSum([Revenue], 12, "month")

A month with no sales contributes nothing to any window it falls in — the zero rule, with no date-spine table required.