cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
KevinJan
Regular Visitor

Determine Shift based on TimeStamp

Hi All,

 

I need help to determine the shift based on the time stamp of my data set. 

Day Shift = 6:00:00 AM to 6:00:00 PM

Night Shift = 6:00:00 PM to 6:00:00 AM (the next day)

 

KevinJan_0-1651053344923.png

Any help is much appreciated.

Thanks

1 ACCEPTED SOLUTION

Hi @KevinJan ,

maybe this will help.

if DateTime.Time([time]) > Time.From("6:00:00") and DateTime.Time([time]) < Time.From("18:00:00") then "Day Shift" else "Night Shift"

 

shiftPQ.png

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #
"Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


View solution in original post

4 REPLIES 4
mh2587
Solution Sage
Solution Sage

column=
VAR _A =
TIME ( 6,00,00 )
VAR _B =
TIME ( 18,00,00 )

RETURN
IF (
[Time Coulmn] >= _A
&& [Time Coulmn] <= _B,
"Day Shift","Night Shift" )



Muhammad Hasnain

#LetsConnect https://www.linkedin.com/in/hasnain2587/

Hi @KevinJan ,

maybe this will help.

if DateTime.Time([time]) > Time.From("6:00:00") and DateTime.Time([time]) < Time.From("18:00:00") then "Day Shift" else "Night Shift"

 

shiftPQ.png

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #
"Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Maybe I am mistaken, but while looking for a similar solution, I believe this is not enough. I have successfully defined the night and day shift by time, but what happens when the last part of the night shift is accounted for in the wrong day? For example, the night shift has 6 hours that happens in the following morning, but needs to be counted as the same shift as the night in which is began. Does this formula account for that?

Hi @villasenorbritt ,
for this requirement you should calculate another column that will tell you the date the value is counted.

 

if DateTime.Time([time]) <= Time.From("6:00:00") then DateTime.Date([time]) - #duration(1,0,0,0) else DateTime.Date([time])

 

ShiftDate.png

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #
"Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors