Forum Discussion
nataliesmiy1357
2 years agoHelper IV
DAX Formula - Time
Hello! I am looking to create a formula that's if this and that, then this with time.
I want: If the time is between 6am-5:10pm, then "First Shift"
and if the time is between 5:25pm - 5:55am, then "Second Shift"
Thanks in advance!
Hi nataliesmiy1357 - create below calculated column in your table, replace your Datetime column as per your model.
Shift Classification =VAR CurrentTime = [DateTime]VAR TimeFirstShiftStart = TIME(6, 0, 0) -- 6:00 AMVAR TimeFirstShiftEnd = TIME(17, 10, 0) -- 5:10 PMVAR TimeSecondShiftStart = TIME(17, 25, 0) -- 5:25 PMVAR TimeSecondShiftEnd = TIME(5, 55, 0) -- 5:55 AM (next day)
RETURNIF ((CurrentTime >= TimeFirstShiftStart && CurrentTime <= TimeFirstShiftEnd) ||(CurrentTime >= TimeSecondShiftStart || CurrentTime <= TimeSecondShiftEnd),"First Shift","Second Shift")Hope it helps
1 Reply
- rajendraongole1Super User
Hi nataliesmiy1357 - create below calculated column in your table, replace your Datetime column as per your model.
Shift Classification =VAR CurrentTime = [DateTime]VAR TimeFirstShiftStart = TIME(6, 0, 0) -- 6:00 AMVAR TimeFirstShiftEnd = TIME(17, 10, 0) -- 5:10 PMVAR TimeSecondShiftStart = TIME(17, 25, 0) -- 5:25 PMVAR TimeSecondShiftEnd = TIME(5, 55, 0) -- 5:55 AM (next day)
RETURNIF ((CurrentTime >= TimeFirstShiftStart && CurrentTime <= TimeFirstShiftEnd) ||(CurrentTime >= TimeSecondShiftStart || CurrentTime <= TimeSecondShiftEnd),"First Shift","Second Shift")Hope it helps