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
Casteless
Helper I
Helper I

Measure Efficiency help: Calculating the average of a measure evaluated in different contexts

 

Hey All,

 

I'm trying to calculate the average value of a measure [Net Reserve] over the past three months. 

 

The below code works but is cumbersome, and would not scale well to formulas that involve more variables/bigger time periods. 

 

Average Net Reserve (3mo) = CALCULATE(

CALCULATE([Net Reserve],PREVIOUSMONTH(Reserve[Month]))+

CALCULATE([Net Reserve],PREVIOUSMONTH(PREVIOUSMONTH(Reserve[Month])))+

CALCULATE([Net Reserve],PREVIOUSMONTH(PREVIOUSMONTH(PREVIOUSMONTH(Reserve[Month]))))

)/3)

 

Any help to optimize this type of calcualtion?

2 REPLIES 2
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Casteless

 

According to your description, you want to calculate the moving average for past three months. Right?

 

In this scenario, you can use DATESINPERIOD() function as filter in CALCULATE() to get the 3 month moving total, then divide by three to get the average.

 

[3 Month Moving Average] =
CALCULATE(SUM(Table[Net Reserve]), 
          DATESINPERIOD(Reserve[Date], 
                        LASTDATE(Reserve[Date]),-3, Month
                       )
         )
/3

 

For more details, please refer to blogs below:

Moving Averages, Sums, Etc.

Rolling 12 Months Average in DAX

Statistical Patterns

 

Regards,

 

 

That calculates the moving average of a column though does it not? [Net Reserve] is a measure in my model. 

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.