Forum Discussion

RussHaight's avatar
RussHaight
New Member
2 years ago
Solved

Calculate total hours worked

This is from SQL backend.I have table named Punch. It has 1 field named TotalTimeHHMM in type text. I want to sum/add the TotalTimeHHMM. The values are in this format. 10:19 which reperesents 10 hour...
  • RussHaight's avatar
    2 years ago

    I figured it out.

     

    Instead of using the TotalTime column which was a conversion fromTotalMinutes column, I just used TotalMinutes column. Example as follows

    TotalMinutes 598.8 (decimal) converts to TotalTime 09:59 (text) with 09 being hours and 59 being minutes. I created a new column with the following dax formula 

    Total Time =
        VAR TotalMinutes = 'punch'[Total Minutes]
        RETURN
            FORMAT(QUOTIENT(TotalMinutes, 60), "0") & " hours " & FORMAT(MOD(TotalMinutes, 60), "0") & " minutes"
     
    which gave me an output of 9 hours 59 minutes. 
     
    I created a measure using the same dax formula and was able to drop it on a card to get total hours worked in hours/minutes output. I then added 2 slicers, one for location and one for employee.
     
    There might be a better way of doing this but this is what I did to get it to work.