Forum Discussion
Using Year-Month Slicer Calculating the Avearge 3 month values of Quarterly values
- Anonymous1 year ago
Hi anusha_2023 ,
Please try code as below to update your measure.
Measure = VAR Reference_Date = MAX('Date'[Date]) VAR NumberofMonths = SWITCH( TRUE(), MONTH(Reference_Date) IN {1, 4, 7, 10}, 22, MONTH(Reference_Date) IN {2, 5, 8, 11}, 23, MONTH(Reference_Date) IN {3, 6, 9, 12}, 24, BLANK() -- Default case ) VAR RollingMonths = DATESINPERIOD( 'Recurring date'[Date], Reference_Date, -NumberofMonths, MONTH ) VAR _R1 = CALCULATE( SUM(BalanceSheetSample[Amount]), REMOVEFILTERS('Date'), KEEPFILTERS(RollingMonths), USERELATIONSHIP('Date'[Date], 'Recurring date'[Date]) ) VAR RollingMonths2 = DATESINPERIOD( 'Recurring date'[Date], Reference_Date, -3, MONTH ) VAR _R2 = CALCULATE( SUM(BalanceSheetSample[Amount]), REMOVEFILTERS('Date'), KEEPFILTERS(RollingMonths2), USERELATIONSHIP('Date'[Date], 'Recurring date'[Date]), ALLSELECTED('Recurring Date') ) RETURN IF(MAX('Recurring Date'[YearQuarter]) = FORMAT(Reference_Date,"YYYY")&"/Q"&FORMAT(Reference_Date,"Q"),_R2,_R1)Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi anusha_2023 ,
It seems that we don't have permission to your data source link.
Please approve our request or you can share a new link with public permission to us.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I have granted the permission to access the file
- Anonymous1 year agoNot applicable
Hi anusha_2023 ,
Please try code as below to update your measure.
Measure = VAR Reference_Date = MAX('Date'[Date]) VAR NumberofMonths = SWITCH( TRUE(), MONTH(Reference_Date) IN {1, 4, 7, 10}, 22, MONTH(Reference_Date) IN {2, 5, 8, 11}, 23, MONTH(Reference_Date) IN {3, 6, 9, 12}, 24, BLANK() -- Default case ) VAR RollingMonths = DATESINPERIOD( 'Recurring date'[Date], Reference_Date, -NumberofMonths, MONTH ) VAR _R1 = CALCULATE( SUM(BalanceSheetSample[Amount]), REMOVEFILTERS('Date'), KEEPFILTERS(RollingMonths), USERELATIONSHIP('Date'[Date], 'Recurring date'[Date]) ) VAR RollingMonths2 = DATESINPERIOD( 'Recurring date'[Date], Reference_Date, -3, MONTH ) VAR _R2 = CALCULATE( SUM(BalanceSheetSample[Amount]), REMOVEFILTERS('Date'), KEEPFILTERS(RollingMonths2), USERELATIONSHIP('Date'[Date], 'Recurring date'[Date]), ALLSELECTED('Recurring Date') ) RETURN IF(MAX('Recurring Date'[YearQuarter]) = FORMAT(Reference_Date,"YYYY")&"/Q"&FORMAT(Reference_Date,"Q"),_R2,_R1)Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- anusha_20231 year ago
Helper IV
Perfect Answer. Thank you very much. It worked lika a charm that I am struugling to solve in so many ways