Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Rolling Interval Calculation

Hi,

 

My dataset is as follows

 

Year     Month      Day_of_Month     Values

   .           .                        .                     .  

2017     12                     31                    5

2018     1                       1                     10

2018     1                       2                     20

and so on

 

I want to calculate Rolling Interval Calculation on basis of filter rolling interval (1-12)

If i select interval 1 then formula should give aggegated measure for past 30 days,

if i select interval 2 then formula should give aggregated measure for past 60 days and so on.

So far i am using the below mentioned formula which aggregates monthwise only i.e for 1-jan-2018 the calculation should show sum of values for 2-dec-2017 to 1-jan-2018. My calculation currently aggregates only inside a month so for 1-jan-2018 it shows the same value 10.

 

SumValues=Sum([Values])

 

Rolling inteval calculation :-IF([Selected Interval]=1,
CALCULATE([SumValues],
DATESINPERIOD(Table[DATE],LASTDATE(Table[DATE]),-30,DAY)
),
IF([Selected Interval]=2,
CALCULATE(Table[SumValues],
DATESINPERIOD(Table[DATE],LASTDATE(Table[DATE]),-60,DAY)
)
)

 

Please help.

Thanks in advance

 

Power BI User

8 Replies