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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate period

Hallo everyone,

 

If I have this table and I want to calculate for each ID the duration between the end time and the start time of the next event. 

 

In the column marked in green is the value I want to calculate. 

 

 

time between.jpg

Could you please helop out there? 

 

I know dateiff will calculate but only in the same raw but what I need is in different rows. 

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create measure like DAX below.

 

 

DiffTime= 
Var _ThisTime = SELECTEDVALUE(Table1[Event time])

Var _SecondTime= CALCULATE(MIN(Table1[Start time]),FILTER(ALLSELECTED(Table1), Table1[ID] =MAX(Table1[ID]) && Table1[Event time] >_ThisTime ))

Return

DATEDIFF(_ThisTime , _SecondTime, MINUTE )

 

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create measure like DAX below.

 

 

DiffTime= 
Var _ThisTime = SELECTEDVALUE(Table1[Event time])

Var _SecondTime= CALCULATE(MIN(Table1[Start time]),FILTER(ALLSELECTED(Table1), Table1[ID] =MAX(Table1[ID]) && Table1[Event time] >_ThisTime ))

Return

DATEDIFF(_ThisTime , _SecondTime, MINUTE )

 

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.