Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
kyen27
New Member

3 months rolling average display for each month

Hello,

 

I have a data table with something that looks like this.

kyen27_1-1741321937107.png

and I want to create a measure that will allow me to create a matrix table that display the 3 month rolling average for each month, that looks something like this:

kyen27_2-1741322118237.png

 

I have tried so many formulas looking at similar posts and even asking AI but no luck. I keep getting the same result where each period column displays the average of all transactions in its own month. or where it would display the sum of each month and the grand total would display the average of the latest 3 months of the entire data set.

 

any help is appreciated.

 

Thanks,

 

4 REPLIES 4
vivek31
Resolver II
Resolver II

HI @kyen27 ,

you can try this formula 

3M moving avg 2 = 
var period = DATESINPERIOD('Calendar'[DateKey],MAX('Calendar'[DateKey]),-3,MONTH)
var sales = CALCULATE([total_sales],period)
VAR month_ = CALCULATE(DISTINCTCOUNT('Calendar'[MonthOfYear]),period)
RETURN
DIVIDE(sales,month_)

vivek31_0-1741328011334.png

If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

Hello,

 

thank you for your response but i dont have a date column.

bhanu_gautam
Super User
Super User

@kyen27 Create a measure

DAX
3MonthRollingAvg =
CALCULATE(
AVERAGEX(
DATESINPERIOD(
'Table'[Period],
LASTDATE('Table'[Period]),
-3,
MONTH
),
'Table'[Amount]
)
)

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hello, i get an error saying this:

 

kyen27_0-1741356870816.png

 

Helpful resources

Announcements