Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

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 8
LivioLanzo
Solution Sage
Solution Sage

Hi @Anonymous,

 

the correct way to handle this is through the creation of a Date dimension table but it does not look like it is the case for you?

 

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Anonymous
Not applicable

I don't have a date dimension , but a date column in  my Table

 

Power BI User

@Anonymous

 

you need to start by creating one: http://radacad.com/create-a-date-dimension-in-power-bi-in-4-steps-step-1-calendar-columns

 

 

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Anonymous
Not applicable

Hi Liviolanzo,

 

I have created date dimension.

Now what do i need to do to calculate rolling interval.

 

Power BI User

Hi @Anonymous

 

perfect! Now you can relate the Date dimension with the fact table if not already done. Afterwards you need to mark it as a Date table

 

Then you just need to change the filter within CALCULATE to point to the date dimension

 

DATESINPERIOD(DateTable[DATE],MAX(DateTable[DATE]),-60,DAY)

 

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Anonymous
Not applicable

Hi LivioLanzo,

 

 

I tried doing this but it still gives me same result.

However while going through few test sets i realized this is not the problem.

Actually whenever i am using side filters (Year , Month , Day of Month) , the data set is filtered out hence it does not calculate rolling.

For example : if i select complete 2018 , then calculation is correct from 31 Jan 2018 onwards for Rolling Interval-1

If i select Feb-2018 only , data for Jan is filtered out , hence it gives sum of only february which is not the required result.

 

How do i make the filters work with the calculation.

 

Power BI User

 

Can you show a screen shot or share your file? You may need to created a disconnected table

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Anonymous
Not applicable

Hi LivioLanzo,

 

I have attached Power BI File and Excel data source.

 

Value Rolling Average RI is the final required measure.

It gives correct data values when i select the complete data set that is year 2017 and 2018 both.

If i select only 2018 and check data values for rolling interval-1 , Month-January-2018 (i.e data for past 30 days) , it shows incorrect results because data for dec-2017 is filtered out.

I want it work with the side filters that is if user wants to select only one month and view data , it should give correct rolling average.

 

Please let me know if the attachment does not open.

 

Power BI File

Data

 

 

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors