Forum Discussion

Piersj1994's avatar
Piersj1994
Frequent Visitor
3 years ago
Solved

time Tracking

Hello I have been trying for awhile now to make a Time tracking solution that will display Co workers Time that they worked within a system. I have a Excel sheet that has A Date/Time Column, Also hav...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Piersj1994,

    Any other fields exist in your table records that can be used to recognize the user status? Or these records are sorted based on the datetime values as sort order and odd/even number as group?(odd : sign in, even: sign out)

    If that is the case, you can use these filed or try to add a new column to check records odd/even number based on current user id and datetime values to return the sign in/out status.

    Status =
    VAR rowCount =
        COUNTROWS (
            FILTER (
                'Table',
                [UserID] = EARLIER ( 'Table'[UserID] )
                    && [Datetime] <= EARLIER ( 'Table'[Datetime] )
            )
        )
    RETURN
        IF ( MOD ( rowCount, 2 ) = 1, "In", "Out" )

    Then you can extract the hour part from the datetime values and calculate the duration include in current hour period.
    If current 'In' and 'Out' status is in the same period, calculation should be the 'Out - In’.
    For other scenario, calculation will be split to two parts. The ‘In’ part required to calculate the difference between 'In' to the 'end of current time period'. For the 'Out', you can calculate the difference between previous 'In’ record end period and the current 'Out'.
    For 'Out' to 'In', these records should be excluded from calculations because user has out of the work.

    Regards,

    Xiaoxin Sheng