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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Rolling sum of days, based on different dates

Hi

 

I'm trying to create a table that calculates the rolling total number of days that someone is booked to do work, based on the last date they are expected to work (which could be in the past or in the future). The number of days may not equate exactly to the start and end dates that someone is booked to work eg they could be booked to work 5 days in a 20 day period. What I do have is the name of the person, start and end dates and the number of days booked to work.

Here is some sample data. 

 

NameStart dateEnd dateNumber of days
Person A01 March 202105 March 20215
Person A02 March 202120 March 20216
Person A09 March 202120 April 20217
Person A01 October 202103 October 20213
Person A10 May 202211 May 20222
Person B05 November 202207 November 20223
Person B01 June 202110 June 20214
Person B10 August 202214 August 20225

 

So for person A, I want BI to work out that the latest date they are booked to finish working on is 11 May 2022 and calculate that the total number of days in the preceding 12 months (or 365 days) is 5. If they were then booked to work another 5 days between 10th and 14th October 2022 then it would calculate the latest date to be 14 October 2022 and change the calculated number to be 7. I then have person B who is working different dates but I want the total for them to appear in the table as well.

So I want my table to look something like this

NameRolling 12 months number of daysLatest date for calculation
Person A511 May 2022
Person B807 November 2022

 

and when a new date and number of days is added, to look like this

 

NameRolling 12 months number of daysLatest date for calculation
Person A714 October 2022
Person B807 November 2022

 

Either it's something really simple or too complicated for me to have been able to work out to do so far. I do have a date table that can read the dates.

 

Help please, wise people!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please try these measures.

Latest date for calculation = 
CALCULATE ( MAX ( 'Table'[End date] ), 'Table'[Name] = MAX ( 'Table'[Name] ) )
Rolling 12 months number of days = 
CALCULATE (
    SUM ( 'Table'[Number of days] ),
    DATESINPERIOD ( 'Table'[End date], [Latest date for calculation], -365, DAY )
)

Results:

vcgaomsft_0-1657268214520.png

The PBIX file is attached for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Please try these measures.

Latest date for calculation = 
CALCULATE ( MAX ( 'Table'[End date] ), 'Table'[Name] = MAX ( 'Table'[Name] ) )
Rolling 12 months number of days = 
CALCULATE (
    SUM ( 'Table'[Number of days] ),
    DATESINPERIOD ( 'Table'[End date], [Latest date for calculation], -365, DAY )
)

Results:

vcgaomsft_0-1657268214520.png

The PBIX file is attached for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

amitchandak
Super User
Super User

@Anonymous , Check if this blog can help in this case

 

https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-or-end-date/ba-p/1503785

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.