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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Extracting Latest 4 Points of a Measure

Hi,

 

I am having an issue extracting the latest 4 points of a measure. The measure I used is a rolling average and its function is as follows:

Moving_Average = 

CALCULATE(
SUMX('table','table'[Sales]),
DATESINPERIOD(
'table'[Quarter_Date].[Date],
LASTDATE('table'[Quarter_Date]),
-4,
QUARTER
)
)
 
The moving average formula works fine. Then I tried to extract the last 4 points' Moving Average by implement a filter, but the filter recalculated the moving averages.  Following is the filter I implemented:
VAR Last_4_Roll_4 = CALCULATE([Moving_Average], 'table'[Quarter_Order] <= 4)
 
Return 
Last_4_Roll_4
 
So is there a way to implement a filter that truncates the output after the measure being calculated?
 
Thanks,
TS
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi Jimmy,

 

Thanks for answering.

 

Applying Filter function actually interrupt with the moving average and turn the output back to standalone points. 

 

But applying the filter directly without the Filter function seem to work in this case.

 

Result =
VAR Last_4_Roll_4 =
    CALCULATE ( [Moving_Average], 'table'[Quarter_Order] <= 4 )
RETURN
    Last_4_Roll_4

 

Thanks,

TS 

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

@Anonymous,

 

Have you solved your issue by now? If you have, could you please help mark the correct answer to finish the thread? Your contribution will be much appreciated.

 

Regards,

Jimmy Tao

v-yuta-msft
Community Support
Community Support

Hi TXTS23,

 

Modify your measure as below and check if it can work:

Result =
VAR Last_4_Roll_4 =
    CALCULATE ( [Moving_Average], FILTER ( 'table', 'table'[Quarter_Order] <= 4 ) )
RETURN
    Last_4_Roll_4

Regards,

Jimmy Tao

Anonymous
Not applicable

Hi Jimmy,

 

Thanks for answering.

 

Applying Filter function actually interrupt with the moving average and turn the output back to standalone points. 

 

But applying the filter directly without the Filter function seem to work in this case.

 

Result =
VAR Last_4_Roll_4 =
    CALCULATE ( [Moving_Average], 'table'[Quarter_Order] <= 4 )
RETURN
    Last_4_Roll_4

 

Thanks,

TS 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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