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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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