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
Anonymous
Not applicable

Conversion of Time to equivalent shift

Hi,

 

Would like to know if how will I make a column for the equivalent shift of the given time

Vonn_0-1714270337914.png

 

1st Shift: 6am - 2pm

2nd Shift: 2pm - 10pm

3rd Shift: 10pm - 6am

 

Thank you

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@Anonymous 

you can try this in PQ

 

=if DateTime.Time([Date]) >= #time(6, 0, 0) and DateTime.Time([Date]) < #time(14,0,0) then "1st Shift" else if DateTime.Time([Date]) >= #time(14,0,0) and DateTime.Time([Date]) <#time(22,0,0) then "2nd Shift" else "3rd Shift"

 

11.PNG

 

or create a DAX column

Column =
VAR _time='Table'[Date]-int('Table'[Date])
return if(_time>=time(6,0,0) && _time<time(14,0,0), "1st Shift", if(_time>=time(14,0,0)&& _time<time(22,0,0),"2nd Shift", "3rd Shift"))
 
12.PNG
 
pls see the attachment below
 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Chakravarthy
Resolver II
Resolver II

Hi @Anonymous 

Alternatively you can create calculated column as below using TIME DAX functions:

Shift =
VAR _HOUR = HOUR('Table'[Date])
VAR _MIN = MINUTE('Table'[Date])
VAR _SEC = SECOND('Table'[Date])
VAR _TIME = TIME(_HOUR,_MIN,_SEC)
RETURN
SWITCH(TRUE(),
_TIME>=TIME(6,00,00) && _TIME<TIME(14,00,00),"1st Shift",
_TIME>=TIME(14,00,00) && _TIME<TIME(22,00,00),"2nd Shift",
"3rd Shift"
)

View solution in original post

2 REPLIES 2
Chakravarthy
Resolver II
Resolver II

Hi @Anonymous 

Alternatively you can create calculated column as below using TIME DAX functions:

Shift =
VAR _HOUR = HOUR('Table'[Date])
VAR _MIN = MINUTE('Table'[Date])
VAR _SEC = SECOND('Table'[Date])
VAR _TIME = TIME(_HOUR,_MIN,_SEC)
RETURN
SWITCH(TRUE(),
_TIME>=TIME(6,00,00) && _TIME<TIME(14,00,00),"1st Shift",
_TIME>=TIME(14,00,00) && _TIME<TIME(22,00,00),"2nd Shift",
"3rd Shift"
)
ryan_mayu
Super User
Super User

@Anonymous 

you can try this in PQ

 

=if DateTime.Time([Date]) >= #time(6, 0, 0) and DateTime.Time([Date]) < #time(14,0,0) then "1st Shift" else if DateTime.Time([Date]) >= #time(14,0,0) and DateTime.Time([Date]) <#time(22,0,0) then "2nd Shift" else "3rd Shift"

 

11.PNG

 

or create a DAX column

Column =
VAR _time='Table'[Date]-int('Table'[Date])
return if(_time>=time(6,0,0) && _time<time(14,0,0), "1st Shift", if(_time>=time(14,0,0)&& _time<time(22,0,0),"2nd Shift", "3rd Shift"))
 
12.PNG
 
pls see the attachment below
 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors