Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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)
Solved! Go to Solution.
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
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
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
To learn more about Power BI, follow me on Twitter or subscribe 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. 😊
Assuming you want the result in hours:
Time Worked = (End Time - Start Time)*24 - Personal Time
https://docs.microsoft.com/nl-nl/dax/datediff-function-dax
Proud to be a Super User!
Awesome Keyboard Shortcusts in Power BI, thumbs up if you like the article
My Community Blog Articles (check them out!)
My Blog - Power M code to automatically detect column types -
How to create test data using DAX!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
12 | |
10 | |
10 | |
6 |