The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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)
Any help is much appreciated.
Thanks
Solved! Go to 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"
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
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" )
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
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"
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
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])
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
80 | |
71 | |
51 | |
50 |
User | Count |
---|---|
129 | |
123 | |
78 | |
64 | |
60 |