Forum Discussion

tex628's avatar
tex628
Community Champion
8 years ago
Solved

Calculating working hours

Hello,   I have a table that looks like this:    I need to calculate the hours between the created on/at and the finalized on/at.  We count all hours that occur, 24/7 except for weekends...
  • kohlivinayak's avatar
    8 years ago

    Hi tex628

     

    I tried recreating your scenario and calculating no of days excluding weekend days.

     

    So I created a date dimention and with weeknum function got saturdays (6) and sundays(7) in a new column in date dimention.

     

     

     

     

     

     

     

     

     

     

     

     

    And in my start and end date table first calculated datediff in no of days

    and then no of weekend days in between these two days by creating new column using formula as

     

    Weekend Days =
    var _stdate = Working[Date 1]
    var _enddate = Working[Date 2]
    return
    CALCULATE(COUNT('Date Dim'[Date]),FILTER('Date Dim','Date Dim'[Day Name] =6 || 'Date Dim'[Day Name] = 7),FILTER('Date Dim','Date Dim'[Date]>= _stdate && 'Date Dim'[Date] <= _enddate))

     

    And lastly subtracting both

     

     

     

     

     

     

     

     

     

     

    Thanks

    Vinayak Kohli