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

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors