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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
NekoGTz
New Member

If/Then Between Times

Good Morning All,

I think I'm overcomplicating here but I'm struggling to create a calculated column to identify "Work Shift" by looking at the hours of the day.

 

I have my times split into a single column.

 

NekoGTz_0-1673969863953.png

 

I need one column that looks at the times and displays what shift that falls under.

 

0600AM to 0200PM = "Days"

0201PM to 1000PM = "Afternoons"

1001PM to 0559AM = "Midnights"

 

Any help is greatly appreciated.

 

Nick

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @NekoGTz ,

 

The basic syntax for your new column will be like this:

if [ReceivedTime.2] >= #time(06, 00, 00) and [ReceivedTime.2] < #time(14, 00, 00) then "Days"
else ...etc

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

Hi @NekoGTz ,

 

The basic syntax for your new column will be like this:

if [ReceivedTime.2] >= #time(06, 00, 00) and [ReceivedTime.2] < #time(14, 00, 00) then "Days"
else ...etc

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Pete - Can't thank you enough! I've been scratching my head for days with incorrect time format.

 

Final statement is: (and works perfectly)

 

if [ReceivedTime.2] >= #time(06, 00, 00) and [ReceivedTime.2] < #time(14, 00, 00) then "Days" else if [ReceivedTime.2] >= #time(14, 01, 00) and [ReceivedTime.2] < #time(22, 00, 00) then "Afternoons" else "Midnights"

Hi @NekoGTz ,

 

Glad this got you sorted.

You just need to adjust your second line to the following, otherwise you'll miss any times between 14:00:00 and 14:00:59 :

[ReceivedTime.2] >= #time(14, 00, 00)  // changed to 14:00:00

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
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.