# Moving Average Analytic Function

This article describes how to use the Moving Average analytic function in Arcadia Enterprise.

We are using the Basic Visual for Aggregates to demonstrate how to use the Moving Average analytic function.

1. Click the field on the measurement shelf, in this case, the `sum(population)` field on the Y Axis shelf.
2. In the Field Properties menu, expand Analytic Functions, and select Moving Average.
3. In the Analytic Function: Moving Average modal window,

1. In Select aggregate for this measure, leave the default Sum. The other aggregation options are Count, Minimum, Maximum, and Average. In addition, some connection types also support Approximate Distinct Count and Exact Distinct Count.
2. Under Select entities over which to calculate moving averages, select year. This is the grouping that applies when calculating the moving average.
3. Under Select the sort order, you can specify the order of sorting. This order specifies what the row is, and the row where the value is taken. If your visual already specifies sorting order, these values appear in the modal.

You can add additional sort parameters, by clicking the (add/plus) icon.

Here, leave the default order: year ascending, followed by country ascending.

4. Under Rows to include in the average (relative to current row), the options for leading rows are: All previous rows, Current row, or Previous row(s) (default). Select the last option, then specify the number of preceding rows for the calculation; the default is 5, but we changed it to 2.

Similarly, the options for following rows are: All forward rows, Current row (default), or Forward row(s). Select the last option; the default is 5, but we changed it to 2.

``````avg(sum([population])) over (partition by [year] order by [year], [country]