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
lherbert501
Post Partisan
Post Partisan

Non- Moving Average with Slicer

Hi there,

 

I have my measure below but its giving me a moving average instead of the 6 months static.

 

I am trying to get the Result column in the second image below but for only 6 months, so it doesn't change when the slicer date changes. Is this possible?

 

testy =
var NumOfMonths = 6
var LastSelectedDate = MAX(RS_Dates[DateFull])
var Period = DATESINPERIOD(RS_Dates[DateFull], LastSelectedDate,  -NumOfMonths,  MONTH)
Var Result =
CALCULATE(
AVERAGEX(
    VALUES(RS_Dates[PeriodCal]),
    [Outstanding]),Period, ALL(Sales))
return
Result

 

1234.PNG

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @lherbert501,

 

Please try:

Average = 
var _a = MAXX('RS_Dates',[DateFull])
return CALCULATE(AVERAGEX(ALL('Table'),[Outstanding]),DATESINPERIOD('RS_Dates'[DateFull],_a,-6,MONTH))

Final output:

vjianbolimsft_0-1661236446452.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-jianboli-msft
Community Support
Community Support

Hi @lherbert501,

 

Please try:

Average = 
var _a = MAXX('RS_Dates',[DateFull])
return CALCULATE(AVERAGEX(ALL('Table'),[Outstanding]),DATESINPERIOD('RS_Dates'[DateFull],_a,-6,MONTH))

Final output:

vjianbolimsft_0-1661236446452.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-jianboli-msft ,

 

If the "Outstanding" was a measure and not in a column, would this still work or change at all?

 

Thanks

 

Liam

Thankyou @v-jianboli-msft 

amitchandak
Super User
Super User

@lherbert501 , You have try a measure like this example

 

6 Month Avg = CALCULATE(AverageX(Values('Date'[MONTH Year]),calculate(Sum('Table'[Value)))
,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-6,MONTH))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

Unfortunately, this measure outputs the same as the running average, as displayed in the image.

 

Would you have any idea how to get to the required result column??

 

Thanks

 

Liam

 

Capture1.PNG

hi @amitchandak ,

 

Is this possible?

 

Thanks so much in advance

 

Liam

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.