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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
v-cgao-msft
Community Support
Community Support

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
v-cgao-msft
Community Support
Community Support

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.