Forum Discussion

Ashfaq's avatar
Ashfaq
Regular Visitor
7 years ago
Solved

Calculate Hours Late for Employee

Hello Experts,

 

I do have below data sets in my Source Database table.

The standard in and out times of employees are from 08:00 A.M till 02:00 P.M.

 

EmpDateRef_IN_TimeIN_TimeRef_OUT_TimeOUT_Time
1015-Dec-188:008:5014:0012:10
1025-Dec-188:009:0014:0013:30
1035-Dec-188:0010:4514:0011:30
1045-Dec-188:008:0014:0014:00
1055-Dec-188:008:0014:0014:00


for Example emp 101 is late for 50 Minutes in morning and he left early and he is late for 1 hour 50 Minutes in evening.

So in total ths employee is late for 2:40 2 hour and 40 Minutes for today.
In power BI I need to Calculate No of hours each employee he is absent in HH:MM

 

EmpDateRef_IN_TimeIN_TimeRef_OUT_TimeOUT_TimeLateStatus
1015-Dec-188:008:5014:0012:102:40Late
1025-Dec-188:009:0014:0013:301:30Late
1035-Dec-188:0010:4514:0011:302:45Late
1045-Dec-188:008:0014:0014:000:00Ontime
1055-Dec-188:008:0014:0014:000:00

Ontime

 

 

Now I need to Populate last 2 coulumns in power BI, Can somebody please provide there inputs on how to solve this.

  • I would do this in 3 columns:

     

    Column = DATEDIFF([Ref_IN_Time],[IN_Time],MINUTE)+DATEDIFF([OUT_Time],[Ref_OUT_Time],MINUTE)
    
    
    Status = IF([Column]=0,"On Time","Late")
    
    
    Late = 
    VAR __hours = INT([Column]/60)
    VAR __minutes = [Column] - 60*__hours
    RETURN CONCATENATE(CONCATENATE(__hours,":"),__minutes)

3 Replies

  • AlB's avatar
    AlB
    Icon for Community Champion rankCommunity Champion

    Hi Ashfaq

    Employee 103 shouldn't be 2:45+ 2:30= 5:15 hours late?

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    I would do this in 3 columns:

     

    Column = DATEDIFF([Ref_IN_Time],[IN_Time],MINUTE)+DATEDIFF([OUT_Time],[Ref_OUT_Time],MINUTE)
    
    
    Status = IF([Column]=0,"On Time","Late")
    
    
    Late = 
    VAR __hours = INT([Column]/60)
    VAR __minutes = [Column] - 60*__hours
    RETURN CONCATENATE(CONCATENATE(__hours,":"),__minutes)
    • Ashfaq's avatar
      Ashfaq
      Regular Visitor

      Thank you Greg_Deckler, It worked like a charm,

       

      I do have one more question, But i will open another post for that.

       

      Regards

      ASHFAQ