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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
FransArnaud
Regular Visitor

how do I calculate the total working time per day, per week, per year

I have a table with different times for different technicians each day. I would like to calculate the total worked time per day per technician, per week, per month, and per year. What is the correct DAX formula for this? I already have several calculations. The total time per day per technician seems to be correct. However, when I try to display this in a matrix table per week or per month, it doesn't sum up the times. It keeps looking at the first time and the last time per period. Who has a suitable solution?

Example:

FransArnaud_0-1701077729544.png

 

1 ACCEPTED SOLUTION
speedramps
Super User
Super User

Does you column have a time data type?

Time data types have a maximum of 24hrs. 

So if you add 23 + 2 = 1 and not 25!

And 8 + 8 + 8 + 8 + 8 = 16 and not 40.

Try using a decimal data type.

 

View solution in original post

3 REPLIES 3
speedramps
Super User
Super User

Does you column have a time data type?

Time data types have a maximum of 24hrs. 

So if you add 23 + 2 = 1 and not 25!

And 8 + 8 + 8 + 8 + 8 = 16 and not 40.

Try using a decimal data type.

 

To find the first time of the day per technician:

  • Min Time StartArbeid = MIN(PTS_Z14IT_CRM_HR_DAT[StartArbeid])
  • Min Time StartReisHeen = MINX(FILTER(PTS_Z14IT_CRM_HR_DAT,PTS_Z14IT_CRM_HR_DAT[StartReisHeen] <> 0 ),PTS_Z14IT_CRM_HR_DAT[StartReisHeen])
  • Min Time = MINX({[Min Time StartReisHeen],[Min Time StartArbeid]},[Value])

To find the last time of the day per technician:

  • Max Time TijdEindeArbeid = MAX(PTS_Z14IT_CRM_HR_DAT[EindeArbeid])
  • Max Time EindeReisTerug = MAX(PTS_Z14IT_CRM_HR_DAT[EindeReisTerug])
  • Max Time = MAXX({[Max Time EindeReisTerug],[Max Time TijdEindeArbeid]},[Value])

To find the total working time per day per technician:

  • Totale tijd min = CALCULATE(DATEDIFF([Min Time],[Max Time],MINUTE)) //
  • Totale tijd uur = [Totale tijd min]/60

 

Then the ‘Totale tijd min’ provides the total working time in minutes per day. When I place this as a value in a matrix table, I get an incorrect calculation of the total time. Also, when I try to see the total working time per week, I do not get accurate results.

 

FransArnaud_0-1701120138551.png

 

I have a solution. 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors