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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
EZRIDR01
Regular Visitor

Time Calculation

Sorry if this is very rudimentary, but I am new at this and struggling.

 

What is the DAX to calculate the difference in time, or the amount of hours worked for this data? 

 

Essentially I want...

Time Worked = (End Time - Start Time - Personal Time)

 

Time Table.JPG

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

The other responses are good ways to do it in DAX after you've loaded the table, but if you want to do it in the query editor you can add a custom column with this formula

 

=Duration.TotalHours([End Time (Military Time)] - [Start Time (Military Time)]) - [Personal Time Away During Shift (Hours)]

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

The other responses are good ways to do it in DAX after you've loaded the table, but if you want to do it in the query editor you can add a custom column with this formula

 

=Duration.TotalHours([End Time (Military Time)] - [Start Time (Military Time)]) - [Personal Time Away During Shift (Hours)]

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


MahoneyPat- Thank you!  This is what I was looking to accomplish.   Apologies to the others for not using the proper terminology (DAX vs M). 

 

I appreciate everyones efforts. 😊

lbendlin
Super User
Super User

Assuming you want the result in hours:

 

Time Worked = (End Time - Start Time)*24 - Personal Time

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.