# Dax calculation for rolling previous 12 months



## shwetasagar (Apr 12, 2016)

Hi Guys,

I am currently using SSAS tabular model which requires some advanced calculations in DAX. I have got a solution to rolling 12 months problem. But my requirement also includes previous rolling 12 months value too. 

By that I mean, if I have say for an example Aug 2015 date, Last rolling 12 months will give me values from Sep 2014 to Aug 2015. Now I need Previous 12 months too, that is Sep 2013 to Aug 2014.

Can anyone of you please help me with this?

Regards,
Shweta


----------



## shwetasagar (Apr 12, 2016)

shwetasagar said:


> Hi Guys,
> 
> I am currently using SSAS tabular model which requires some advanced calculations in DAX. I have got a solution to rolling 12 months problem. But my requirement also includes previous rolling 12 months value too.
> 
> ...




Got the solution:

IF (
    HASONEVALUE ( datetable[datecolumn] ),
    CALCULATE (
        SUM ( Table[column] ),
        DATESBETWEEN (
            Period[dShortDate],
            FIRSTDATE ( PARALLELPERIOD ( datetable[datecolumn], -23, MONTH ) ),
            LASTDATE ( PARALLELPERIOD ( datetable[datecolumn], -12, MONTH ) )
        )
    ),
    ALL ( datetable[datecolumn] )
)


----------

