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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
sreddy47652
Helper III
Helper III

rolling average for 3 months showing same value

Hi team,

i am trying to create the rolling average for 3 months but it was giving same values as base value, can you help me to fix for rolling average for 3 months.

sreddy47652_0-1732102206763.png

 

7 REPLIES 7
divyed
Resolver III
Resolver III

Hello @sreddy47652 ,

 

You can use below dax for your purpose , please replace table names and fileds:

 

rolling_3_month_Avg =
AVERAGEX(
    WINDOW(
        -2,REL,0,REL,
        ALLSELECTED(Test_Avg[Month_number],Test_Avg[Year],Test_Avg[Users]),
        ORDERBY(Test_Avg[Month_number]),
        PARTITIONBY(Test_Avg[Year])
    ),
    CALCULATE(AVERAGE(Test_Avg[Users])
)
)
 
divyed_0-1732109116311.png

 

Did I answer your query ? Mark this as solution if this helps, appreciate your Kudos.

 

Cheers

 

DataNinja777
Super User
Super User

Hi @sreddy47652 ,

 

Here is a measure for calculating a 3-month rolling average at the month level:

Rolling Average (3 Months) = 
VAR CurrentMonth = MAX('Calendar'[Date])
RETURN 
    AVERAGEX(
        DATESINPERIOD('Calendar'[Date], CurrentMonth, -3, MONTH),
        CALCULATE(SUM('FactTable'[Value]))
    )

 

 

 

This measure calculates the rolling average by using the DATESINPERIOD function to define a 3-month window and then applies AVERAGEX to compute the average for the specified period. The calendar table ensures the calculation respects the relationship with the fact table.

 

Best regards,

johnt75
Super User
Super User

You can try

Rolling Average =
VAR DatesToUse =
    WINDOW (
        -2,
        REL,
        0,
        REL,
        ALLSELECTED ( 'Date'[Year], 'Date'[Month number] ),
        ORDERBY ( 'Date'[Year], ASC, 'Date'[Month number], ASC )
    )
VAR Result =
    AVERAGEX ( DatesToUse, CALCULATE ( DISTINCTCOUNT ( 'Table'[User ID] ) ) )
RETURN
    Result

i tried above forumala but it always return as 1 only instead of rolling average

It works for me, see attached PBIX. I think there must be an issue in the calculation you're using where I put the DISTINCTCOUNT.

shafiz_p
Memorable Member
Memorable Member

Hi @sreddy47652 
It is better to provide representative date to get the exact solution.


However, you could try this:

RollingAvg3Months = 
CALCULATE(
    AVERAGEX(
        DATESINPERIOD(
            'DateTable'[Date],
            LASTDATE('DateTable'[Date]),
            -3,
            MONTH
        ),
        AVERAGE('YourTable'[Value])
    )
)

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

i tried already above formula still returns same values for base value

Helpful resources

Announcements
Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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