Forum Discussion

vissvess's avatar
vissvess
Helper V
6 years ago
Solved

Calculated column for work hour

Hi,   My dataset is as follows.                     I need a column that is work hour index. For example, for a particular day, particular unit status, the earliest of time is hou...
  • vissvess's avatar
    vissvess
    6 years ago

    Thanks AlB for the effort. Also, I'll try to share the table model in further post. Sharing PBIX would not be possible.

     

    The following code worked out.

    Work Hour =
    VAR currentdate =
        CALCULATE ( MIN ( 'Build routing'[Date] ) )
    VAR mintime =
        CALCULATE (
            MIN ( 'Build routing'[End Time] ),
            ALLEXCEPT (
                'Build routing',
                'Build routing'[Date],
                'Build routing'[Unit Status]
            )
        )
    VAR starthour =
        HOUR ( mintime )
    VAR currenthour =
        HOUR ( 'Build routing'[End Time] )
    RETURN
        currenthour - starthour + 1

    This code resulted in the following 

     

     

     

     

     

     

    Thanks for the effort.