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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Vonn
New Member

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

@Vonn 

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 I
Resolver I

Hi @Vonn 

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 I
Resolver I

Hi @Vonn 

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

@Vonn 

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
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.