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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
markefrody
Post Patron
Post Patron

Define Dynamic Time Values Into Shifts

Hi all,

I'm not sure how I can do this in Power BI. Appreciate your kind advice.

I have two tables containing the following:
Table 1: Manager Schedule
Contains the shift schedule and meal (break) time of 2 shift managers per day.

FirstNameLastNameStart TimeBreak StartBreak End
LebronJames09/28/2021 04:00:24 PM09/28/2021 08:31:42 PM09/28/2021 09:01:45 PM
MichaelJordan09/28/2021 04:12:07 AM09/28/2021 08:37:29 AM09/28/2021 09:10:51 AM
LebronJames09/27/2021 05:40:24 PM09/27/2021 09:12:21 PM09/27/2021 10:00:55 PM
MichaelJordan09/27/2021 04:04:29 AM09/27/2021 08:36:38 AM09/27/2021 09:10:23 AM


NOTE: There is no "End Time" in the table.
To get the "End Time", before the “Start Time” of the next shift manager is the “End Time” of the current shift manager.
Just deduct  a second on the start time of the next shift manager to get the current shift manager's "End Time" .

Example:
In September 28, 2021, 
If Michael Jordan’s Start Time is 09/28/2021 04:12:07 AM (current shift manager),
Lebron James’ Start Time is 09/28/2021 04:00:24 PM (next shift manager),
Therefore, Michael Jordan’s End Time would be 09/28/2021 04:00:23 PM


Table 2: Production Schedule
List of products and time when the product was made. Data can be found here:
https://www.dropbox.com/s/7jh2hcycutk0zra/Schedule%20Sample%20Data.xlsx?dl=0 


What I need:
1. Identify which manager does a product fall into:

Product IDDate and Time FinishedShift Manager
   
   


2. Output wherein it will show:

Date FinishedFirst NameLast NameTotal hoursTotal minutesTotal seconds
9/28/2021LebronJames   
9/27/2021MichaelJordan   

a. Date Finished - is the date the when the product was finished. Production for that day.
b. First Name - Manager who is responsible for that product first name.
c. Last Name – Manager who is responsible for that product last name
d. Total hours finished - Computed by getting the (earliest finished time - latest finished time for that day), and removing the time spent during break time. Value should be in hours.
e. Total minutes finished - Computed by getting the (earliest finished time - latest finished time for that day), and removing the time spent during break time. Value should be in minutes.
f.  Total seconds finished - Computed by getting the (earliest finished time - latest finished time for that day), and removing the time spent during break time. Value should be in seconds.


Thank you in advance for any assistance you can provide me. 

Best regards,
Mark V.

 

 

 

3 REPLIES 3
v-janeyg-msft
Community Support
Community Support

Hi, @markefrody 

 

Do you still need help?

In your desired result, Why 2021/9/28 is Lebron not Michael? Is there any logic between this?

vjaneygmsft_0-1634118005484.png

 

Best Regards,

Community Support Team _ Janey

Greg_Deckler
Community Champion
Community Champion

@markefrody While for a different purpose, you essentially need MTBF: See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler - that's a nice pattern. They should turn that into a quick measure. 😉

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.