In this blog we are going to be looking at calculating a moving average using the Multi-Row Formula.
Step 1.
Understand your data. In the example below, each row represents a quarter and we want to understand how the average in changing over time.
![](https://www.thedataschool.co.uk/content/images/2022/10/image-230.png)
Step 2: Choose the correct tool. For this data the 'Quarter' field in a row, so we are going to use the Multi-Row Formula Tool.
![](https://www.thedataschool.co.uk/content/images/2022/10/image-237.png)
Step 3: Select Create New Field and name your new column. Here I have called in 3mo avg Sale.
![](https://www.thedataschool.co.uk/content/images/2022/10/image-247.png)
Step 4: Increase number of rows, for this data we are looking at a 3/4 moving average so we need to increase the Num Rows to 2.
![](https://www.thedataschool.co.uk/content/images/2022/10/image-249.png)
Step 4: Group by. Here we are going to Group by Region. Next, write an expression. ([Sales]+[Row-1:Sales]+[Row-2:Sales])/3.
![](https://www.thedataschool.co.uk/content/images/2022/10/image-254.png)
This expression is basically saying, sum the current row sales, with the row before and the row before that, then divide by 3 because we are trying the 3/4 moving average.
Output:
![](https://www.thedataschool.co.uk/content/images/2022/10/image-257.png)
And that is it, you have calculated a moving average.