Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Days in a row Calculation

Hello everyone,

 

I have a specific case to solve and I need your help after a few hours of trying hard unsuccessfully.

 

Here is the context:

 

I have a Timesheet table which is structured as follows :

Each person puts the number of hours the days they are working OR on leave

 

IDLastnameDateNbHours
1Person A25/08/20228
1Person A26/08/20228
1Person A29/08/20228
2Person B22/08/20228
2Person B29/08/20228
3Person C26/08/20228
3Person C27/08/20228
3Person C28/08/20228
3Person C02/09/20228

 

And I have a "Leave Table" with the leaves for each person :

IDLastnameStart DateEnd Date
1Person A22/08/202226/08/2022
2Person B10/08/202214/08/2022
2Person B20/08/202201/09/2022
3Person C02/09/202205/09/2022

 

 

These tables are obviously simplified ones but this is the idea

The two tables are linked through the ID with a *-* relationship (impossible to do another way)

 

What I need is to list the people that have worked more than 7 days in a row, and show how many days in a row they have been working (if there are multiple periods with more than 7 days for a single person, show the max)

Thing to notice : the people put hours in the timesheet also for their leaves so we need to use the "Leave Table" to not count the dates between Start and End columns

 

In this example, no one works more than 7 days in a row of course but we should have :

IDLastnameMax days in a row
1Person A1
2Person B0
3Person C3

 

 

I hope this is clear enough for you to understand and I hope someone will be able to help me.

 

Thank you in advance !

2 Replies