cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Resolver I
Resolver I

Need Help: Rolling Average (Last 2 days) | When multiple dates in a column

I have an original table using which I need to calculate the rolling average of rating table. However I do not get the expected output. Can somebody please help me with a DAX solution for this ? 
Please refer the image below:
1.JPG
Any help would be appreciated !

1 ACCEPTED SOLUTION

Hi @ketan10

 

Try this MEASURE

 

Rolling 2 Days Average =
AVERAGEX (
    TOPN (
        2,
        FILTER (
            ALL ( TableName[Date] ),
            TableName[Date] <= SELECTEDVALUE ( TableName[Date] )
        ),
        TableName[Date], DESC
    ),
    CALCULATE ( AVERAGE ( TableName[Rating] ) )
)
Regards,
Zubair


View solution in original post

3 REPLIES 3
Frequent Visitor

I replicated your data and chose Average of Rating instead of Sum or Don't summarize etc..Average of rating.png

Hi @ketan10

 

Try this MEASURE

 

Rolling 2 Days Average =
AVERAGEX (
    TOPN (
        2,
        FILTER (
            ALL ( TableName[Date] ),
            TableName[Date] <= SELECTEDVALUE ( TableName[Date] )
        ),
        TableName[Date], DESC
    ),
    CALCULATE ( AVERAGE ( TableName[Rating] ) )
)
Regards,
Zubair


View solution in original post

@ketan10

 

rollingavg.png

Regards,
Zubair


Helpful resources

Announcements
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Wave Release 2

Check out the updates in Power BI.

Overview of Power BI 2020 release wave 2!

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors