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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Find the duration of the event

IDEventtime 
1start06-04-2020 15:00
1mid time 06-04-2020 15:10
1end 06-04-2020 15:14
2start06-04-2020 18:00
2mid time 06-04-2020 18:20
2end 06-04-2020 18:40

 

I would like to find duration of each event - so to have in table that event "1" latest 14 min and event 2 lasted 40 min 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try a measure like

sumx(summarize(table, table[ID], "_1", datediff(minx(filter(table,table[Event]="start"),table[time]),maxx(filter(table,table[Event]="end"),table[time]), minute)),[_1])

View solution in original post

Hi @Anonymous ,

 

Just helping you on the above solution. 

 

You are creating a Calculated Column, while the solution is given for a measure.

 

Create a New Measure

 

Regards,

Harsh Nathani

View solution in original post

7 REPLIES 7
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

kindly find my below results:

Measure = var a = MINX(FILTER(ALL('Table'),[ID]=MAX('Table'[ID])),[time ])
var b = MAXX(FILTER(ALL('Table'),[ID]=MAX('Table'[ID])),[time ])
return
DATEDIFF(a,b,MINUTE)

03.PNG 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
amitchandak
Super User
Super User

@Anonymous , Try a measure like

sumx(summarize(table, table[ID], "_1", datediff(minx(filter(table,table[Event]="start"),table[time]),maxx(filter(table,table[Event]="end"),table[time]), minute)),[_1])

Anonymous
Not applicable

@amitchandak  Would it be possible to apply the solution as a calculated column instead of measure? 

Anonymous
Not applicable

Capture1.JPG

@amitchandak So this is my orginal table and I am trying to calculate timw between "All Fast" and "Pilot off". the table is called "PortStayEvents (R)" So my code looks like this:

Capture1.PNGBut it doesnt work... Could you advise me what to do ? 

Hi @Anonymous ,

 

Just helping you on the above solution. 

 

You are creating a Calculated Column, while the solution is given for a measure.

 

Create a New Measure

 

Regards,

Harsh Nathani

Anonymous
Not applicable

Hi @amitchandak , Thank you for your suggestion. The problem is that I have 300 different IDs.. and in your solution you calculated time for only one ID - "1" right ? 

@Anonymous , No, it is for everything

_1 is the name of the column in summarize table

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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