Forum Discussion
Anonymous
7 years agoNot applicable
Calculate working hours within a date range
Hi there I have three tables. A basic one with employees, aka Employee Aileen Tom Barbara Another one with their workoing hours per day (multiple entries per day are possible)...
- 7 years ago
Hi Anonymous ,
Create the following measure:
Hours = CALCULATE ( SUM ( WorkingHours[working hours] ); FILTER ( ALL ( WorkingHours[Date] ); WorkingHours[Date] >= SELECTEDVALUE ( Periods[From] ) && WorkingHours[Date] <= SELECTEDVALUE ( Periods[To] ) ) )Regards,
MFelix
- 7 years ago
Hey Anonymous ,
this is a slightly different solution than the one MFelix provided.
Please be aware that my solution also requires a calendar tarble (though it does not have to be related to one of the tables).
Create this measure:
Working Hours = SUMX( VALUES(Period) ,CALCULATE( SUM(Working[working hours]), TREATAS(DATESBETWEEN('Calendar'[Date],'Period'[From],'Period'[To]),Working[Date]) ) )Regards,
Tom
MFelix
Super User
7 years agoHi Anonymous ,
Create the following measure:
Hours =
CALCULATE (
SUM ( WorkingHours[working hours] );
FILTER (
ALL ( WorkingHours[Date] );
WorkingHours[Date] >= SELECTEDVALUE ( Periods[From] )
&& WorkingHours[Date] <= SELECTEDVALUE ( Periods[To] )
)
)
Regards,
MFelix
TomMartens
Super User
7 years agoHey Anonymous ,
this is a slightly different solution than the one MFelix provided.
Please be aware that my solution also requires a calendar tarble (though it does not have to be related to one of the tables).
Create this measure:
Working Hours =
SUMX(
VALUES(Period)
,CALCULATE(
SUM(Working[working hours]),
TREATAS(DATESBETWEEN('Calendar'[Date],'Period'[From],'Period'[To]),Working[Date])
)
)
Regards,
Tom
- Anonymous7 years agoNot applicable
Thanks TomMartens !
Grüsse nach Hamburg