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
TimothyJames
Frequent Visitor

Sum of minutes in a datetable, when separate table has a datetime within the datetable's datetimes

Hi,

So I work in a factory and I have some data that I cannot figure out how to sum up.

Basically, the intent of this is to get "How many minutes did this person work on this machine out of the full 8 hour shift?"
This will allow me to get a ratio of utilization of our machines compared to what we expect.

 

We expected our employees to get 420 minutes of utilization per shift. (8 hours minus some breaks/lunch/etc)

 

So I have the dataset of inspections.

Inspections 

Inspection TicketStart TimeEnd TimeShift
18/3/2021 6:45 AM8/3/2021 6:55 AM1st
28/3/2021 7:30 AM8/3/2021 7:35 AM

1st

 

 

So on and So Forth.

 

I also have a datetime column that has this data

 

DateShiftShift Start TimeShift End TimeShift Start DatetimeShift End DatetimeMax Minutes Available
8/3/20211st12/30/1899 6:30 AM12/30/1899 2:30 PM8/3/21 6:30 AM8/3/21 2:30 PM

420

8/3/20212nd12/30/1899 2:30 PM12/30/1899 10:30 PM8/3/21 2:30 PM8/3/21 10:30 PM

420

8/3/20213rd12/30/1899 10:30 PM12/30/1899 6:30 AM8/3/21 10:30 PM8/4/21 6:30 AM

420

       

 

Here's what I would expect to see.

Minutes of Inspection Time =

iferror(
    SUMX ( inspections,datediff(Inspections[inspection_time_in],Inspections[inspection_time_out],MINUTE )
           ),blank()) 

Therefore 15 minutes of inspection time

I would also like to see 420 minutes of inspection time available.
15/420 = .035714 or 3.57% of 420

I have the minutes of inspection time done comfortable, but I cannot identify how I sum up available time if the inspection occured in that window of time.
 
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @TimothyJames ,

 

Step 1: Create a relationship between Inspections and datetime with shift column.

Step 2: Create a calculate column to Inspections.

_diff = DATEDIFF(Inspections[Start Time],Inspections[End Time],MINUTE)

Step 3: Create a measure.

Measure = SUM(Inspections[_diff])/SUM(datetime[Max Minutes Available])

1.PNG

 

Best Regrads,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

1 REPLY 1
v-jayw-msft
Community Support
Community Support

Hi @TimothyJames ,

 

Step 1: Create a relationship between Inspections and datetime with shift column.

Step 2: Create a calculate column to Inspections.

_diff = DATEDIFF(Inspections[Start Time],Inspections[End Time],MINUTE)

Step 3: Create a measure.

Measure = SUM(Inspections[_diff])/SUM(datetime[Max Minutes Available])

1.PNG

 

Best Regrads,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

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.