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 September 15. Request your voucher.

Reply
GunnerJ
Post Patron
Post Patron

Find the difference in time after sorting by Service Order # and Time

I'm needing to find out how long certian tasks are taking. I have the columns BI_EVENT_DT_TM, BI_SO_NBR, and BI_TASK_CD. There's also BI_WRKFLW_TASK_SEQ_NBR but tasks are not always completed in the correct order so the sequence number can't be used. 

 

In order to get the needed results I need to have my dataset order by BI_SO_NBR so I'm just finding times for tasks within their respective service order, then order by BI_EVENT_DT_TM ascending. After they're ordered in the formula I then need to subtract the time between one line's BI_EVENT_DT_TM by the BI_EVENT_DT_TM of the task that was completed after it.

 

So if the a service order had 2 tasks in it one timed at 12:00:00 and the next at 12:00:10 I would get a value of 10 seconds or 00:00:10 for "TASK TIME" for the first task.

 

This code is close but not there yet. It returns the running sum of time for each Service order and the results are off by one row.

 

Column = VAR temp =
TOPN (
1,
FILTER (
Query1,
Query1[BI_SO_NBR] = EARLIER (Query1[BI_SO_NBR])
&& Query1[BI_EVENT_DT_TM] < EARLIER (Query1[BI_EVENT_DT_TM] )
),
Query1[BI_SO_NBR], DESC, Query1[BI_EVENT_DT_TM],ASC
)
RETURN
DATEDIFF ( MINX ( temp, Query1[BI_EVENT_DT_TM] ), Query1[BI_EVENT_DT_TM], SECOND)

  

Date Set SampleDate Set SampleHopeful End ResultHopeful End Result

0 REPLIES 0

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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