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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

calculate time duration from the same column

Hello, I have a table with four columns: 'id', 'bay_id','dosage' and 'chemical' as below:

 
 

bi.JPG

My question is that how can I calculate time duration when dosage is greater than 0 on a specific chemical status with the same bay_id. For example, for bay_id = 3528, Alkaline has been used twice, from '15/05/2020 17:01:39' to '15/05/2020 17:03:11'(duration is 01:32) and from '15/05/2020 17:03:53' to '15/05/2020 17:05:24' (duration is 01:31) so the total duration is 03:03.

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Create two columns like

Min time =maxx(FILTER('Table',[ID]=EARLIER([ID]) && [bay_id]=EARLIER([bay_id]) && [time_chemi]<EARLIER([time_chemi]) && [dosage]<>EARLIER([dosage])),[time_chemi])

max Time=minx(FILTER('Table',[ID]=EARLIER([ID]) && [bay_id]=EARLIER([bay_id]) && [time_chemi]>EARLIER([time_chemi]) && [dosage]<>EARLIER([dosage])),[time_chemi])

 

and then a measure like this

duration =

sumx(summarize(Table,table[ID], table[bay_id], Table[Min time],Table[max Time]),datediff([Min time],[max Time],minute))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks for the replay.

 

How can I convert duration in second to the format HH:mm:ss?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors