Forum Discussion

frankhofmans's avatar
frankhofmans
Helper IV
2 years ago
Solved

Average x function combined with date table

hi all,

 

i have two tables:

 

Datetable

 

DateIsworkingday
24-5-20241
25-05-20240
26-05-20240
27-05-20241
28-05-20241
29-05-20241
30-05-20241
31-05-20241
01-06-20240

 

And table: cases

 

CaseIdStartdateEnddate
C00101-02-202430-04-2024
C00201-04-202410-04-2024
C00301-05-202427-06-2024
C00410-05-202430-06-2024
C00501-06-202410-07-2024
C00601-06-2024

03-06-2024

   

 

I want to calculate the following results:

 

Number of active cases: # of cases with at least 1 day in the selected period (startdatum <= max of selected date, enddate >= min of selected date)

Number of active days: sum of all days between startdate case (or min of selected date if startdate < min selected date) and enddate (or max of selected date if enddate > max selected date), but only the days that have a 1 in column isworkingday in the date table

Average duration: number of active days / number of active cases

 

Do you have a suggestion? the cases table has over 500k rows.

 

Thanks in advance,

 

Regards, Frank