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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors