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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
frankhofmans
Helper IV
Helper IV

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

1 ACCEPTED SOLUTION
_AAndrade
Super User
Super User

Hi @frankhofmans,

I'm attaching a pbix file wiht my solution.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




View solution in original post

1 REPLY 1
_AAndrade
Super User
Super User

Hi @frankhofmans,

I'm attaching a pbix file wiht my solution.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.