Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello,
I would like to calculate duration of Start/Stop of multime events at the time of event Stop. Below is the example. How can I write measure/column in DAX to calculate the duration?
Date TimeEventsDuration (hr)
1/11/2020 1:00 | Start A | |
1/11/2020 2:00 | Stop A | 1 |
1/11/2020 3:00 | Start A | |
1/11/2020 3:00 | Others | |
1/11/2020 4:15 | Start B | |
1/11/2020 5:00 | Stop B | 0.75 |
1/11/2020 6:00 | Stop A | 3 |
1/11/2020 7:00 | Start C | |
1/11/2020 8:00 | Start A | |
1/11/2020 9:00 | Stop C | 2 |
1/11/2020 10:00 | Start B | |
1/11/2020 11:00 | Stop A | 3 |
1/11/2020 11:30 | Stop B | 1.5 |
Best Regards,
Zin.
Solved! Go to Solution.
Hi @zinminthant
You'd have to split the Events column to have the type of the event (Start, Stop...) and the name of the entity the event happens on (A, B...) in separate columns. Best to do this in Power query. Then you can create a column like this:
Duration (hr) =
VAR previousStart_ =
CALCULATE (
MAX ( Table1[DateTime] ),
ALLEXCEPT ( Table1, Table1[Entity] ),
Table1[Event Type] = "Start",
Table1[DateTime] < EARLIER ( Table1[DateTime] )
)
RETURN
IF ( Table1[Event Type] = "Stop", ( Table1[DateTime] - previousStart_ ) * 24 )
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
See it all at work in the attached file.
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
See it all at work in the attached file.
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Hi @zinminthant
You'd have to split the Events column to have the type of the event (Start, Stop...) and the name of the entity the event happens on (A, B...) in separate columns. Best to do this in Power query. Then you can create a column like this:
Duration (hr) =
VAR previousStart_ =
CALCULATE (
MAX ( Table1[DateTime] ),
ALLEXCEPT ( Table1, Table1[Entity] ),
Table1[Event Type] = "Start",
Table1[DateTime] < EARLIER ( Table1[DateTime] )
)
RETURN
IF ( Table1[Event Type] = "Stop", ( Table1[DateTime] - previousStart_ ) * 24 )
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
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 |
---|---|
63 | |
55 | |
53 | |
36 | |
34 |
User | Count |
---|---|
85 | |
74 | |
55 | |
45 | |
43 |