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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
mluanacruz
Helper I
Helper I

Average 3 to Average 6 not working

Hi,

I am trying to replicate this measure where I take the average of the ratio from the past 3 months to the past 6 months:

Ratio_Measure 3mth =
VAR DEV_MNT = MAX('PD_agg_perf_measures'[DEV_MONTHS])

VAR NuM = CALCULATE(SUM('PD_agg_perf_measures'[CNP_CNT_ACCOUNTING_VIEW]),FILTER(ALLSELECTED('PD_agg_perf_measures'),[DEV_MONTHS]= DEV_MNT&&[ACCIDENT_DATE_YYYYMM]=MAX('PD_agg_perf_measures'[ACCIDENT_DATE_YYYYMM])))

VAR DEN = CALCULATE(SUM('PD_agg_perf_measures'[CNP_CNT_ACCOUNTING_VIEW]),FILTER(ALLSELECTED('PD_agg_perf_measures'),[DEV_MONTHS]=DEV_MNT-1 &&[ACCIDENT_DATE_YYYYMM]=MAX('PD_agg_perf_measures'[ACCIDENT_DATE_YYYYMM])))

VAR Link_Ratio = DIVIDE(NuM, DEN,0)

Var Last_Date = LASTDATE('Calendar'[Date])

VAR mth_3 = AVERAGEX(DATESINPERIOD('Calendar'[Date], DEV_MNT,-3,MONTH),Link_Ratio)

Return mth_3
 
 
I tried to just replace the -3 with -6 for the average of the past 6 months but it is not working. Can someone help me, please?

Thanks in advance.
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@mluanacruz , You need to have measures like

Monthly Avg like

 

Rolling 3 = calculate(AverageX(Values('Date'[MONTH Year]), DIVIDE(NuM, DEN,0) ),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

or

 

Rolling 3 = CALCULATE( DIVIDE(NuM, DEN,0) ,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

from 3 to 6 month

Rolling 3 = CALCULATE( DIVIDE(NuM, DEN,0) ,DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date ]),-3) ,-3,MONTH))

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

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@mluanacruz , You need to have measures like

Monthly Avg like

 

Rolling 3 = calculate(AverageX(Values('Date'[MONTH Year]), DIVIDE(NuM, DEN,0) ),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

or

 

Rolling 3 = CALCULATE( DIVIDE(NuM, DEN,0) ,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

from 3 to 6 month

Rolling 3 = CALCULATE( DIVIDE(NuM, DEN,0) ,DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date ]),-3) ,-3,MONTH))

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.