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

Join 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.

Reply
Anonymous
Not applicable

Count duration over overlapping dates across multiple date range

Hi,

I’m very much new in power bi. it is my first post and need your help to get the correct duration. We open multiple job orders in our workshop for equipment at a time. I just want to calculate the correct duration from the table. Especially for the yellow highlighted equipment where the minimum start date is 3/26/2021 11:00:00 AM and the maximum end date is 4/14/2021 7:07:34 PM and both are on a different row.

 

Job Order No_Equipment No_Start DateEnd DateDuration(hours)Remarks
580258413/26/2021 11:00:00 AM04-12-2021 18:2703/26/2021 11:00:00 AM minimum date
576058413/26/2021 1:41:24 PM3/27/2021 4:00:00 PM0 
19458413/26/2021 4:00:00 PM4/14/2021 7:07:34 PM4644/14/2021 7:07:34 PM Maximum date
18458413/30/2021 4:00:00 PM4/14/2021 6:56:27 PM0 
33458414/23/2021 10:07:34 AM4/23/2021 1:00:00 PM3 
583584105-10-2021 12:0005-10-2021 13:001 
64254325/19/2021 10:25:51 AM5/19/2021 12:00:00 PM2 
1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

try to create a measure like this:

_Duration(hours) = 
var _table=FILTER(ALLEXCEPT('Table','Table'[Equipment No_]),DATEDIFF([Start Date],MAX([Start Date]),DAY)=0)
var _minS=CALCULATE(MIN([Start Date]),_table)
var _maxE=CALCULATE(MAX([End Date]),_table)
return DATEDIFF(_minS,_maxE,HOUR)

result:

vangzhengmsft_0-1627006487844.png

Please refer to the attachment below for details

 

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
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-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

try to create a measure like this:

_Duration(hours) = 
var _table=FILTER(ALLEXCEPT('Table','Table'[Equipment No_]),DATEDIFF([Start Date],MAX([Start Date]),DAY)=0)
var _minS=CALCULATE(MIN([Start Date]),_table)
var _maxE=CALCULATE(MAX([End Date]),_table)
return DATEDIFF(_minS,_maxE,HOUR)

result:

vangzhengmsft_0-1627006487844.png

Please refer to the attachment below for details

 

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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