A moving average smooths a noisy line: each point becomes the average of itself and the points before it. In QuickSight it is windowAvg, a table calculation over the rows of the visual.

Copy and paste

3-month trailing average (this month and the two before):

windowAvg(sum({Sales}), [truncDate('MM', {Order Date}) ASC], 2, 0)

Only when the window is full:

ifelse(
  windowCount(sum({Sales}), [truncDate('MM', {Order Date}) ASC], 2, 0) = 3,
  windowAvg(sum({Sales}), [truncDate('MM', {Order Date}) ASC], 2, 0),
  NULL
)

7-day trailing average on a daily visual:

windowAvg(sum({Sales}), [{Order Date} ASC], 6, 0)

Centred 3-month average (one before, one after):

windowAvg(sum({Sales}), [truncDate('MM', {Order Date}) ASC], 1, 1)

Example

Month Sales windowAvg 2, 0 Full windows only
Jan 2026 100 100.00
Feb 2026 120 110.00
Mar 2026 90 103.33 103.33
Apr 2026 110 106.67 106.67
May 2026 130 110.00 110.00
Jun 2026 100 113.33 113.33

The indexes count other rows

windowAvg(measure, [sort], start, end) takes the rows from start rows above the current one to end rows below it, and the current row is always included. A 3-month average is therefore 2, 0, not 3, 0. 3, 0 averages four months: in the example, April would show 105.00 instead of 106.67. The AWS example windowSum(..., 12, 0) labelled “trailing 12-month sum” has the same problem: it adds up 13 rows.

Partial windows

At the start of the series there are fewer rows than the window needs, and windowAvg averages what is there: January is the average of one month, February of two. On a chart these points look like real 3-month averages. windowCount with the same arguments returns how many rows the window holds, and the second formula shows the average only when it holds all three.

Gaps in the dates

The indexes count rows, not months. If a month has no sales, it has no row, and the window reaches one month further back than intended. A table with every month, even those with zero sales, avoids that: join a calendar of months in the dataset, or fill the gaps in the source query. The effect is shown with numbers in how to calculate a rolling 12-month total.

Filters

Like every table calculation, the average sees only the rows left after filters. If the visual is filtered to start in March, March becomes a one-month window. Load the earlier months and hide them with a filter on a table calculation, as described in the rolling total guide.

Checked against the Amazon Quick Sight function reference (October 2026). The example results were recomputed in DuckDB.

References