DAX Expression – How to determine Shift in “Shift” column based on Time in “Time” Column

DAX Expression – How to determine Shift in “Shift” column based on Time in “Time” Column

  • Post category:Power BI
  • Post last modified:March 24, 2021
  • Reading time:2 mins read

Case statement

CASE
WHEN CONVERT(VARCHAR(8), datetime, 108) BETWEEN
’07:00:00′ AND ’14:59:00′ THEN ‘Day’
WHEN CONVERT(VARCHAR(8), datetime, 108) BETWEEN
’15:00:00′ AND ’22:59:00′ THEN ‘Evening’
ELSE ‘Night’
END AS ShiftName

You can also use Switch statement

WorkShift = SWITCH(TRUE(),[Time] >= TIME(7, 0, 0) && [Time] < TIME(15,0,0), “DAY”, [Time] >= TIME(15,0,0) && [Time] < TIME(23,0,0), “Evening”,
“Night”)

Leave a Reply