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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.