Forum Discussion

AquaLyzer's avatar
AquaLyzer
New Member
2 years ago
Solved

Spilt Calculated Duration with Overlapping Dates for Same Record - Power Query

Hello,

I've spent quite some time trying to resolve an issue related to calculating "Out of Compliance Days" for a dataset, and I could really use some help. I've searched through the forum, but so far, I haven't found a solution that fits my specific scenario.

 

I'm working with a dataset similar to the tables below: students are required to submit their projects within 10 days. However, complications arise when students go on sick leaves, leading to the creation of duplicate records for the same student and project. When a student is on sick leave, the system generates a resolution date, set to 5 days after the last sick day.

 

Please note that whether a student is on sick leave or not, "Out of Compliance Days" should still be calculated based on the days between the project due date and the submission date.

 

The standard calculation of the duration between "Submission Date" and "Project Due Date," falls short when there are multiple exceptions, as shown in the example for Project ID 532:

Student NameProject IDProject Due DateSick Start DateSick End DateResolution dateSubmission DateOut Of Compliance Days
Student 175326/11/20236/2/20236/8/20236/13/20236/16/20235
Student 175326/11/20236/9/20236/15/20236/20/20236/16/20235
Student 104894/2/20234/26/20234/27/20235/2/20234/28/202326
Student 036014/27/20234/28/20234/28/20235/3/20234/29/20232
Student 083983/30/20234/22/20234/24/20234/29/20234/24/202325


I'm looking to add a column that calculates and splits the "Out of Compliance Days" by exception for the same project ID. I expect the results to reflect this:

Student NameProject IDProject Due DateSick Start DateSick End DateResolution dateSubmission DateOut Of Compliance Days
Student 175326/11/20236/2/20236/8/20236/13/20236/16/20232
Student 175326/11/20236/9/20236/15/20236/20/20236/16/20233
Student 104894/2/20234/26/20234/27/20235/2/20234/28/202326
Student 036014/27/20234/28/20234/28/20235/3/20234/29/20232
Student 083983/30/20234/22/20234/24/20234/29/20234/24/202325

 

I'm at a loss as to how to achieve this, and I would greatly appreciate any help, tips, or guidance. Thanks in advance.

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi AquaLyzer ,

     

    Here's the result:

     

    You can check mroe details from my attachment.

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi AquaLyzer ,

     

    Here's the result:

     

    You can check mroe details from my attachment.

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.