cancel
Showing results for 
Search instead for 
Did you mean: 
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
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.