Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Sxbbb
Creator III
Creator III

I need shift field = Morning Afternoon Night

I have Field 

Sxbbb_0-1724836892978.png

 

Morning shift time 06.00-13.59 hrs. Afternoon shift 14.00-21.59 hrs. Night shift 22.00-05.59 hrs. I need shift field = Morning Afternoon Night I want to bring time TimeStartDowntime to TimeFinishDowntime is divided into shifts.

EX

StartDowntime ='11:42:40' to FinishDowntime ='23:03:38'
The shifts are morning, afternoon, and night.

I need a field that displays values ​​like this.

Sxbbb_1-1724836937567.png

 

5 Replies
BrunPierre
Partner - Master
Partner - Master

Try this.

If(TimeStartDowntime >= PurgeChar(MakeTime(06,00,00),'AMP') and TimeFinishDowntime <= PurgeChar(MakeTime(13,59,59),'AMP'), 'Morning',
If(TimeStartDowntime >= PurgeChar(MakeTime(14,00,00),'AMP') and TimeFinishDowntime <= PurgeChar(MakeTime(21,59,59),'AMP'), 'Afternoon',
If(TimeStartDowntime >= PurgeChar(MakeTime(22,00,00),'AMP') and TimeFinishDowntime <= PurgeChar(MakeTime(05,59,59),'AMP'), 'Night' ))) as Shift

Sxbbb
Creator III
Creator III
Author

No. Is there another way?

Sxbbb_0-1724896930089.pngSxbbb_1-1724896949182.png

 

BrunPierre
Partner - Master
Partner - Master

Could you share a sample of the data?

Sxbbb
Creator III
Creator III
Author

Sxbbb_0-1724987396840.png

 

BrunPierre
Partner - Master
Partner - Master

Retry with this.

If((Time(TimeStartDowntime) >= Time('06:00:00') and Time(TimeStartDowntime) <= Time('13:59:59')), 'Morning',
If((Time(TimeStartDowntime) >= Time('14:00:00') and Time(TimeStartDowntime) <= Time('21:59:59')),'Afternoon',
If((Time(TimeStartDowntime) >= Time('22:00:00') and Time(TimeStartDowntime) <= Time('23:59:59')) or (Time(TimeStartDowntime) >= Time('00:00:00') and Time(TimeStartDowntime) <= Time('05:59:59')),'Night'))) as CheckPart_Shift