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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Time between start and stop from previous step

Hi!

 

I have investigated heavely in the forum, but have not been able to solve my issue.

I am using the following data set and need to calculate the time between two operations.

From when the previous ended till the next one start. The different orders can have a different variety of steps, but the Jobid can always be sorted to know the correct order:

JeppeUldall_0-1646905147421.png

I have tried to highlight the date times i want to calculate the difference between, on the first line for each modulerefid i expect to be 0.

 

2 ACCEPTED SOLUTIONS
johnt75
Super User
Super User

You could do this in a calculated column, but there are is a caveat. If you know that the previous job will always finish before the current one starts then

Time between jobs =
var currentStartTime = 'Table'[Start Time]
var currentModule = 'Table'[ModuleRefID]
var prevEndTime = CALCULATE( MAX( 'Table'[End Time]), 'Table'[ModuleRefID] = currentModule,
'Table'[End Time] < currentStartTime )
return DATEDIFF( prevEndTime, currentStartTime, MINUTE )

You can change the granularity of the DATEDIFF to whatever you need.

View solution in original post

Try changing the prev end time line to

var prevEndTime = CALCULATE( MAX( 'Table'[End Time]), REMOVEFILTERS('Table'),
'Table'[ModuleRefID] = currentModule,
'Table'[End Time] < currentStartTime )

 

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

You could do this in a calculated column, but there are is a caveat. If you know that the previous job will always finish before the current one starts then

Time between jobs =
var currentStartTime = 'Table'[Start Time]
var currentModule = 'Table'[ModuleRefID]
var prevEndTime = CALCULATE( MAX( 'Table'[End Time]), 'Table'[ModuleRefID] = currentModule,
'Table'[End Time] < currentStartTime )
return DATEDIFF( prevEndTime, currentStartTime, MINUTE )

You can change the granularity of the DATEDIFF to whatever you need.

Anonymous
Not applicable

Hi

I have just tested your solution but i do not get any values.

JeppeUldall_0-1646907445511.png

 

Try changing the prev end time line to

var prevEndTime = CALCULATE( MAX( 'Table'[End Time]), REMOVEFILTERS('Table'),
'Table'[ModuleRefID] = currentModule,
'Table'[End Time] < currentStartTime )

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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