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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
RDN_03
Frequent Visitor

How to creating rolling average for last 6 months using period slicer,

Getting correct for last 6 mnths as per below measure but my rolling average giving wrong values.

Last6mnths_rcvd =
VAR Referencedate =MAX(Dates[Date])
VAR Previousdates = DATESINPERIOD(Las6mnthsTabble[Date],
Referencedate,-6,MONTH
)
VAR Result= CALCULATE([Total_received],
REMOVEFILTERS(Dates),
KEEPFILTERS(Previousdates),
USERELATIONSHIP(Dates[Date],Las6mnthsTabble[Date])
)
RETURN
Result
RDN_03_0-1708424752526.png

above is correct  for last 6 mnths .

 

below measure for rolling average 

rolling average last 6 mnths =
VAR Referencedate =MAX(Dates[Date])
VAR Previousdates = DATESINPERIOD(Las6mnthsTabble[Date],
Referencedate,-6,MONTH
)
VAR Noofmnths=6
VAR Rolling= CALCULATE([Total_received]/6,DATESINPERIOD(Dates[Date],LASTDATE(Las6mnthsTabble[Date]),-Noofmnths,MONTH),
REMOVEFILTERS(Dates),
KEEPFILTERS(Previousdates),
USERELATIONSHIP(Dates[Date],Las6mnthsTabble[Date])
)
RETURN
Rolling
 
RDN_03_1-1708424908489.png

where im going wrong.. my correct value for average shoudl be as below

RDN_03_2-1708424976536.png

@amitchandak pls help

 
 
 
2 REPLIES 2
amitchandak
Super User
Super User

@RDN_03 , if date join is active it should be simple like

 

Rolling 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-6,MONTH))

 

else use a measure which already using use relationship

 

Rolling 6 = CALCULATE([Your Measure],DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-6,MONTH))

 

Continue to explore Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
https://medium.com/@amitchandak/power-bi-window-function-3d98a5b0e07f

 

Rolling Months Formula: https://youtu.be/GS5O4G81fww

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

RDN_03_0-1708443005472.png

above is my 1 year sample data, I could achieve the above, where iam removing edit interactions from period and unfiltering for last 6 mnths & visual is static , requirement is it should be dynamic where based on the period selection I need to show last 6 months sales & last 6 months average (example if i select jan24 , it should display last 6 months sales & last 6 mnths average).

 

Pls guide @amitchandak 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.