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 August 31st. Request your voucher.

Reply
skutovicsakos
Helper I
Helper I

time spent between steps while ignoring other id's steps in between

Hi,

 

I want to calculate the time spent between two steps with the same id in a new column.

What I mean, is that even though in time after doc_id 1; step_id 4 it comes doc_id 2; step_id 2, but I want to calculate the time difference between doc_id 1;step 4 and doc_id1; step 5.

 

every doc_id can start with a random step_id, but it is sequential after

 

DOC_IDSTEP_IDSTART_DATEEND_DATE
141/24/2019 1:43:47 PM1/24/2019 1:43:48 PM
221/24/2019 1:43:49 PM1/24/2019 1:43:50 PM
151/24/2019 1:48:42 PM1/24/2019 1:48:43 PM
231/24/2019 1:48:43 PM1/24/2019 1:48:43 PM
341/24/2019 1:51:49 PM1/24/2019 1:51:49 PM
241/24/2019 1:51:50 PM1/24/2019 1:51:52 PM
161/25/2019 9:11:12 PM1/25/2019 9:11:12 PM
351/25/2019 9:11:28 PM1/25/2019 9:11:28 PM



1 REPLY 1
stevedep
Memorable Member
Memorable Member

Like this?

_SD = 
var _doc = SELECTEDVALUE('Table'[DOC_ID];"Multiple")
var _sd = SELECTEDVALUE('Table'[START_DATE])
return
DATEDIFF(
CALCULATE(MAX('Table'[END_DATE]);FILTER(ALL('Table');'Table'[DOC_ID]=_doc && 'Table'[START_DATE] < _sd))
; MIN('Table'[START_DATE]);MINUTE)

as seen here:

datediff.jpg

File available here

 

Pls mark as solution if it works for you. Thumbs up for the effort is appreciated.

Kind regards, Steve. 

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.