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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors