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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ganapathya
Frequent Visitor

Difference hours between two columns one is first row and next is in another row

Start DateEnd datedowntime
08-06-201408:55:3508-06-201409:55:35 
08-06-201413:55:3508-06-201413:55:354

 

I want to calculate downtime in hrs based on the end date of first row and start date of the second row, also  at the start of everyday downtime value should be empty

1 ACCEPTED SOLUTION

Hi @ganapathya,

 

You can try to use below formula:

 

down time = 
DATEDIFF(MAXX(FILTER(ALL(Sheet2),[ID]=EARLIER(Sheet2[ID])&&[End date]<EARLIER(Sheet2[Start Date])),[End date]),[Start Date],HOUR)+0

 

 3.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

6 REPLIES 6
v-shex-msft
Community Support
Community Support

Hi @ganapathya,

 

I'd like to suggest you use power query to add a index column, then use this index column to calculate time diff.

1.PNG

 

Calculate column:

down time = DATEDIFF(MAXX(FILTER(ALL(Sheet6),[End date]<EARLIER(Sheet6[Start Date])),[End date]),[Start Date],HOUR)+0

2.PNG

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

IDStart DateEnd datedowntime
Machine 108-06-201408:55:3508-06-201409:55:354
Machine 108-06-201413:55:3508-06-201415:55:351
Machine 108-06-201416:55:3508-06-201417:55:352
Machine 108-06-201419:55:3508-06-201423:55:350
Machine 209-06-201400:30:0009-06-201401:30:002
Machine 209-06-201403:30:0009-06-201405:30:002
Machine 209-06-201407:30:0009-06-201423:59:590

 

For this above table ,same Query will work or some change is  required please help me

No sir, it is not working downtime has showing different data, please check the below data

 provide the changes accordingly

Chamber Starttimeendtimedowntime
CH14/25/2016 9:00:11 pm4/26/2016 7:58:53 am0
CH14/26/2016 8:28:21 Am4/26/2016 5:44:19 Pmendtime of row 1-starttime of row 2
CH14/26/2016 6:37:08 Am4/27/2016 3:25:36 amendtime of row 2 -starttime of row3
CH14/27/2016 4:03:24 am4/27/2016 12:57:32 amendtime of row 3-starttime of row 4
CH14/27/2016 5:29:00 pm4/28/2016 2:44:38 amendtime of row 4 -starttime of row5
ch14/28/2016 12:09:09pm4/28/2016 8:36:55pmendtime of row 5 -starttime of row 6

Hi @ganapathya,

 

You can try to use below formula:

 

down time = 
DATEDIFF(MAXX(FILTER(ALL(Sheet2),[ID]=EARLIER(Sheet2[ID])&&[End date]<EARLIER(Sheet2[Start Date])),[End date]),[Start Date],HOUR)+0

 

 3.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

basically i want to calculate the hoursbasically i want to calculate the hours

For example, i have date with time, same date ch1 start time and end time consider runs from 6 AM to 8.15 AM,then again from 10 AM to 11 pm...Now the downtime is 1.45 hrs...from 8.15 AM (End time of row 1) to 10 AM (Start Time Row 2)....

Hi @ganapathya,

 

Please double check your sample data if it contains the wrong records:

5.PNG

 

After I modify the highlight part, the formula works well.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors