Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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_ID | STEP_ID | START_DATE | END_DATE |
1 | 4 | 1/24/2019 1:43:47 PM | 1/24/2019 1:43:48 PM |
2 | 2 | 1/24/2019 1:43:49 PM | 1/24/2019 1:43:50 PM |
1 | 5 | 1/24/2019 1:48:42 PM | 1/24/2019 1:48:43 PM |
2 | 3 | 1/24/2019 1:48:43 PM | 1/24/2019 1:48:43 PM |
3 | 4 | 1/24/2019 1:51:49 PM | 1/24/2019 1:51:49 PM |
2 | 4 | 1/24/2019 1:51:50 PM | 1/24/2019 1:51:52 PM |
1 | 6 | 1/25/2019 9:11:12 PM | 1/25/2019 9:11:12 PM |
3 | 5 | 1/25/2019 9:11:28 PM | 1/25/2019 9:11:28 PM |
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:
File available here.
Pls mark as solution if it works for you. Thumbs up for the effort is appreciated.
Kind regards, Steve.
Proud to be a Super User!
Awesome Keyboard Shortcusts in Power BI, thumbs up if you like the article
My Community Blog Articles (check them out!)
My Blog - Power M code to automatically detect column types -
How to create test data using DAX!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |