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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Get total working time from start and end time in rows

Hello,

 

I have a dataset as follow:

 

NameEmployee CodeTimestampItem qty
activity1_startemp110:0024
activity2_startemp210:1520
activity1_endemp110:1224
activity2_endemp211:0020
activity3_startemp112:0010
activity3_endemp113:1510

 

What I'm trying to do is calculate the actual working time of each employee (12 + 75 mins for emp1; 45 mins for emp2 in this case), then the item/minute for each employee.

 

Thank you in advance for your help.

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , please find the attached solution after signature

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak, thank you for the prompt response.

 

When I open your file, I got the error "Object reference not set to an instance of an object".

 

Can you please have a look at that again? Thank you!

@Anonymous , Please the new column I created

Column = if( right(([Name]),3) = "end" ,datediff( Maxx(FILTER(Sheet1,[Employee Code]=EARLIER(Sheet1[Employee Code]) && [Timestamp] <EARLIER([Timestamp]) && right(([Name]),5) = "start" ),[Timestamp]),[Timestamp],MINUTE),BLANK())

 

Please Watch/Like/Share My webinar on Time Intelligence: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184
My Youtube Tips at: https://www.youtube.com/playlist?list=PLPaNVDMhUXGYrm5rm6ME6rjzKGSvT9Jmy
Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Many thanks for your help @amitchandak 

 

I was able to write another formula based on your idea, without having to use EARLIER:

 

Time spent on task =
var CurrentEmployee = Sheet[Employee]
var CurrentTimestamp = Sheet[Timestamp]
return
if( right(([Name]),3) = "end", datediff( Maxx(FILTER(Sheet, Sheet[Employee] = CurrentEmployee && Sheet[Timestamp] <= CurrentTimestamp && right(([Name]),5) = "start" ), Sheet[Timestamp]), Sheet[Timestamp],MINUTE),BLANK())

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors