How it works...

We begin by initializing the date we are working with, __Date, and the table where we will be averaging values, __Sales. We then set how many weeks backward and forward that we want to include in our averages for any particular day and store these in the variables __WeeksBack and __WeeksForward, respectively. 

We can use these variables to calculate the start and end dates of our rolling weeks in the __RollingWeekStartDate and __RollingWeekEndDate variables. In the case of __RollingWeekStartDate, we simply need to use date subtraction to subtract the number of __WeeksBack variable by 7 (seven days in a week). For __RollingWeekEndDate, it is a similar calculation except that we are adding days and we subtract 1 in order to not include the current date.

Once we have the dates to include, we FILTER the table to only include dates within and including our __RollingWeekStartDate and __RollingWeekEndDate variables and use AVERAGEX to average the Value column.