How to calculate a rolling aggregate


How can we calculate a rolling aggrregate ?
e.g. calculate the sum of field for the last 20 years.

Maybe by loopin over every year and then in the iteration filter the dataset on the last 20 years and aggregating that data ?


For an additive metric like sum, a rolling aggregate is a difference between two cumulative aggregations one of which is shifted by N where N is the rolling window. See the example below.

rolling-sum.morph (2.2 KB)