Forum Discussion

jackisc's avatar
jackisc
New Member
2 years ago
Solved

Plz help with Dax

My clock in and clock out date is in rows. Below DAX helped me subtract the break time of 45 minutes from the employees who worked 8hrs or more perday since it's mandatory. However, I wanted to edit...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi  jackisc ,

     

    Here are the steps you can follow:

    1. In Power Query -- add Column – Index Column – From 1.

    2. Create calculated column.

    Date_time =
    [Date]+[Time]
    Test01 =
    var _last=
    MAXX(
        FILTER('Table',
        'Table'[Index.1]=EARLIER('Table'[Index.1])-1&&'Table'[In/Out]="In"),[Date_time])  
    return
    DATEDIFF(
       _last, [Date_time] , HOUR)
    Test02 =
    var _result=
    IF(
        [Test01]=BLANK(),
    MAXX(
        FILTER(ALL('Table'),'Table'[Index.1]=EARLIER('Table'[Index.1])+1&&'Table'[In/Out]="Out"),[Test01]),[Test01])
    return
    IF(
        _result>=8,"8hr - subtracting 45 minutes of break time","6hr - no need to subtract break time")

    3. Result:

     

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly