Forum Discussion

Ethanhunt123's avatar
Ethanhunt123
Icon for Helper IV rankHelper IV
6 years ago
Solved

Rolling last months / Weeks

I have two tables ( A calendar table (4/4/5 logic), Sales table) I want to calculate the rolling average of last 3/6/12 Months and also last 13/26/52 weeks. For example, If I would calculate for Apri...
  • V-lianl-msft's avatar
    5 years ago

    Hi Ethanhunt123 ,

     

    Refer to:

    Measure =
    IF (
        MAX ( Sales[Date] ) <= MAX ( DimDate[Date] )
            && MAX ( Sales[Date] ) >= EDATE ( MAX ( DimDate[Date] ), -3 ),
        CALCULATE (
            AVERAGE ( Sales[Sales] ),
            FILTER (
                ALL ( Sales ),
                Sales[Date] <= MAX ( DimDate[Date] )
                    && Sales[Date] >= EDATE ( MAX ( DimDate[Date] ), -3 )
            )
        )
    )

    Sample .pbix

     

    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.