Forum Discussion

ggargan's avatar
ggargan
Frequent Visitor
3 years ago
Solved

Problems calculating 12 month rolling average

Hello. Havent done this before.   Trying to calculate the 12 month rolling average for a rate (Measure). It doesn't seem to be working and is just returning the same value as the current month's va...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi ggargan ,

    Please try below steps:

    1. below is my test table

    Table:

    2. create a measure with below dax formula

    Measure =
    VAR cur_date =
        SELECTEDVALUE ( 'Table'[Date] )
    VAR tmp =
        CALCULATETABLE (
            VALUES ( 'Table'[Sales] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Date] IN DATESINPERIOD ( 'Table'[Date], cur_date, -12, MONTH )
            )
        )
    RETURN
        AVERAGEX ( tmp, [Sales] )
    

    3. add a table visual with measure and column

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_ Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.