First I had to determine per specialty the total percentage of surgeries that started outside the regular working hours or in weekends.
The final line became:
=SUMPRODUCT(((Table1[Start surgery]>TIME(17;0;0))*(WEEKDAY(Table1[Surgery date];2)<=5))+((Table1[Start surgery]<TIME(9;0;0))*(WEEKDAY(Table1[Surgery date];2)<=5))+(WEEKDAY(Table1[Surgery date];2)>=6))
Now I want to sum the total surgery time of these surgerys (outside working hours and in the weekend) in the G column (surgery duration).
Help would be very appreciated!