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

Case statement..

Hi,

I have been trying to figure out a way to calculate the out of a column depending on the values of other columns.

From the table below I would like to create an expression to say:

case if Level = 'AOG' and DateTime is between 18:00 and 08:00 (following morning) then 'AOG OO'

     or if Level = 'AOG' and DateTime is on a Weekend then 'AOG OO' Else Level

CustomerLevelDateTime
AAOG2018-05-01 09:08:06
BRoutine2018-05-03 13:23:04
BRoutine2018-05-07 19:11:07
AAOG2018-05-11 23:30:02

OUTPUT REQUIRED:

CustomerOriginalLevelNewLevelDateTime
AAOGAOG2018-05-01 09:08:06
BRoutineRoutine2018-05-03 13:23:04
BRoutineRoutine2018-05-07 19:11:07
AAOGAOG OO2018-05-11 23:30:02

This calculation is being done to work out any levels that fall into out of hours (out of normal working hours).

Thank you in advance for your assistance.

stalwar1youssefbelloum

13 Replies
sasikanth
Master
Master

Try this,

IF(Level = 'AOG'  and  (hour(DateTime)>18 and hour(DateTime)< 8  Or (weekday(DateTime)='Sat' or weekday(DateTime)='Sun'),   'AOG OO' , Level )


Thanks,

Anonymous
Not applicable
Author

Hi Sasi,

This now works for weekends but still does not work for the time period.

Anonymous
Not applicable
Author

Thanks all, I managed to get it working by doing the following:

=IF(PriorityLevel = 'AOG' and (hour(OutTimestamp)>18 and hour(OutTimestamp)<24) Or (AMPM = 'AM' and hour(OutTimestamp)<8) Or (weekday(OutTimestamp)='Sat' or weekday(OutTimestamp)='Sun'),'AOG OOH',PriorityLevel)

Anil_Babu_Samineni

Please mark you response as correct answer, Then?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful