Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I am having problems calculating date difference for the below scenario. I want to calculate the total time spent on a particular job by a mechanic. When the mechanic start and pause we should calculate the difference between the two times, when he resumes and completes the task we should also calculate the difference between the 2nd start time and the completion time, finally we sum the 2 date differences. Time taken = (Pausedtime-Starttime)+( CompleteTime- Starttime)
On the below scenario the expected result is 10 munites
Fleet No. | DocEntry | TaskCode | Task Description | Status | Mechanic | Activity Time | Job Title | Expected Result |
T001 | 3 | SFREN24 | ENGINE OIL LEAK MINOR | Started | Mechanic 1 | 14/03/2018 17:58 | Diesel Mechanic | |
T001 | 3 | SFREN24 | ENGINE OIL LEAK MINOR | Paused | Mechanic 1 | 14/03/2018 18:03 | Diesel Mechanic | 5 min |
T001 | 3 | SFREN24 | ENGINE OIL LEAK MINOR | Started | Mechanic 1 | 15/03/2018 10:40 | Diesel Mechanic | |
T001 | 3 | SFREN24 | ENGINE OIL LEAK MINOR | Stopped | Mechanic 1 | 15/03/2018 10:45 | Diesel Mechanic | 5min |
10 min |
I am a bit of an amateur and there would be a much more sophisticated way to achieve this but this solution worked for me 🙂
Job Duration =
VAR JobStart = CALCULATE(MIN(Table1[Activity Time]), Table1[Status ] = "Started")
VAR BreakStart = CALCULATE(MIN(Table1[Activity Time]), Table1[Status ] = "Paused")
VAR BreakEnd = CALCULATE(MAX(Table1[Activity Time]), Table1[Status ] = "Started")
VAR JobEnd = CALCULATE(MAX(Table1[Activity Time]), Table1[Status ] = "Stopped")
RETURN
CALCULATE(
DATEDIFF(JobStart,JobEnd,MINUTE) - DATEDIFF(BreakStart,BreakEnd,MINUTE)
)
PS: Ignore the 'DocEntry' figure, forgot to remove the quick sum calc 😁
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
8 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
9 |