Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rush
Helper V
Helper V

How to calculate hours worked for each day based on first time in minus last time out?

I currently have a table called acc_monitor_log with columns:

  • time (logs the time when you enter a door & when you exit),
  • device_name (Fire Escape IN, Fire Escape OUT, Front Door IN, Front Door OUT, GTC Office IN, GTC Office Out)
  • pin (which relates to the user)

 

I would like to calculate the hours worked for each day of every month based on the first time they entered for work & the last time, irrespective of the door they entrered or exited.

 

Capcsddsd.PNG

 

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @rush,

 

According to your description, you want to calculate the daily work hours and get the monthly total,right?

 

If this is a case, you can refer to below steps:

 

1. Add a calcuale column to calculate the daily work hours.

 

Daily Diff = 
var temp= FILTER(Table,[Time].[Date]=EARLIER(Table[Time].[Date])&&[Pin]=EARLIER([Pin])&&[device_name]=EARLIER([device_name]))
return
DATEDIFF(MINX(temp,[Time]),MAXX(temp,[Time]),MINUTE)

 

2. Summary above table with same month.

Summary = SUMMARIZE(Table,[Pin],[device_name],[Time].[Month],"Total Minute",SUM(Time[Daily Diff]),"Total Hour",SUM(Time[Daily Diff])/60)

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.