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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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))

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))

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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