Forum Discussion

Estyfodense's avatar
Estyfodense
Icon for Helper I rankHelper I
6 years ago
Solved

Work with hours

i'd like sum the total of hours, day by day and make a table like this 
 start timeFinal hour total hh
02/01/202018:00:0018:30:0000:30:00
02/01/202017:00:0018:00:0001:00:00
02/01/202016:00:0017:00:0001:00:00
02/01/202015:00:0016:00:0001:00:00
02/01/202014:00:0015:00:0001:00:00
02/01/202013:00:0014:00:0001:00:00
02/01/202012:00:0013:00:0001:00:00
02/01/202011:00:0012:00:0001:00:00
02/01/202010:00:0011:00:0001:00:00
02/01/202009:00:0010:00:0001:00:00
02/01/202008:00:0009:00:0001:00:00
04/01/202011:0011:3500:35:00
04/01/202010:0011:0001:00:00
04/01/202009:0010:0001:00:00
04/01/202008:0009:0001:00:00
04/01/202007:3008:0000:30:00

 

To it I'm use 

total hh =SUMX('HH,
'HH'[Final hour ]-'HH'[start time])
after this, a did I Have to create table like that
 DateHours Work totalWork by dayExtra Hour
Thursday02/01/202010:30:0008:00:0002:30:00
Saturday04/01/202004:05:0004:00:0000:05:00

I have to create a measure or Dax that identify the day, For exemple If de day is Saturday it gets the total hours and subtract per 04:00 hrs and to others day get total hours and subtract to 08:00 hrs . In the end I get the extra hour and plot a chart .
  • Estyfodense 

    Try the following formula: Make sure you do the right formatting of duration 13:30:55 (h:nn:ss)

    Total Hours = 
    SUMX(
        hh,
        HH[Final hour ] - HH[start time]
    )
    Net Total Hours = 
    [Total Hours] - IF( WEEKDAY(MAX(HH[Date]),1) = 7 ,TIME(8,0,0), TIME(4,0,0))

     

    Check Day, I 



    ________________________

    Did I answer your question? Mark this post as a solution, this will help others!.

    Click on the Thumbs-Up icon if you like this reply 🙂

    YouTube, LinkedIn

     

  • mahoneypat's avatar
    mahoneypat
    6 years ago

    To get the correct total, use this measure that references the solution @Fowmy

    Total Net SUMX - SUMX(VALUES(HH[Date]), [Net Total Hours])

    If this works for you, mark it as the solution. Praise is also appreciated. Please let me know if you don't.

    Best regards

    Pat

5 Replies