Rolling Average calculations are easy as long as you don’t have to worry about gaps in your dates for which you do not have any transactions. In this tutorial, I boldly take on this challenge and successfully complete the calculation that is able to find the last five days on which the selected product had sales, and then average those sales out to get the rolling (or moving) average.
The Power BI Desktop file can be downloaded here.
The calculation is below:
Rolling 5 Last Days Sales Average =
var lastFiveDaysOfSales = CALCULATETABLE(
), Sales[Date], DESC
‘Date'[Date] <= SELECTEDVALUE(‘Date'[Date])
return DIVIDE(SUMX(lastFiveDaysOfSales, [Sales]), COUNTROWS(lastFiveDaysOfSales))