Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

I need to create two buttons for "Morning" and "Night" shifts

Hello All,

I am a new Qlikview user so I guess my issue might seem easy to you but I need your help with a report I have where I need to create 2 selection buttons one for the morning shift and the other for the night shift so when I click on the morning shift button I get the information and graphs for the data that took place within the morning shift interval which is between 5AM till 4:59 PM and the same for the night shift which starts at 5 PM and ends the next day at 4:59 AM.

the challenge here is with the night shift as it is taking place in 2 different days (5PM till 12 AM and the next day from 12 AM till 4:59AM)

I tried the daystart function but I couldn't make it work.

So could you please advise what should I do to solve this?

1 Solution

Accepted Solutions
MarcoWedel

Hi,

I think former proposed solution meets you requirement to distinguish between morning and night shifts (you just asked for two buttons to do so).

Your requirement to distinguish between individual consecutive shifts is different from your initial question and might be implemented e.g. like this:

QlikCommunity_Thread_314445_Pic7.JPG

QlikCommunity_Thread_314445_Pic6.JPG

QlikCommunity_Thread_314445_Pic1.JPG

QlikCommunity_Thread_314445_Pic2.JPG

QlikCommunity_Thread_314445_Pic3.JPG

QlikCommunity_Thread_314445_Pic4.JPG

QlikCommunity_Thread_314445_Pic5.JPG

QlikCommunity_Thread_314445_Pic8.JPG

tabIncidents:

LOAD *,

    Dual(Shift&' '&ShiftDate, ShiftStart) as ShiftName;

LOAD *,

    DayName(ShiftStart) as ShiftDate,

    If(Time<'05:00' or Time>='17:00','Night','Morning') as Shift;

LOAD *,

    Time#(Time(Frac(DateTime),'hh:mm'),'hh:mm') as Time,

    Timestamp(Floor(DateTime,'12:00','05:00'),'MM/DD/YYYY hh:mm') as ShiftStart;

LOAD RecNo() as IncidentID,

    Timestamp#(Timestamp(Floor(Now()-Rand()*10,1,NORMINV(Rand(),'12:00','04:00')),'MM/DD/YYYY hh:mm'),'MM/DD/YYYY hh:mm') as DateTime

AutoGenerate 10000;

hope this helps

regards

Marco

View solution in original post

8 Replies
m_woolf
Master II
Master II

Its tough to answer this without know what your data looks like.

pooja_prabhu_n
Creator III
Creator III

Hi,

Assuming your date is in timestamp format M/D/YYYY h:mm:ss[.fff] TT.

you can use the below logic:

If(Frac(Date) >= MakeTime(5) and Frac(Date) <= MakeTime(17), 'Day', 'Night') as Flag

Refer this thread for more information

https://community.qlik.com/thread/213240

Hope this helps

Thanks,

Pooja

Anonymous
Not applicable
Author

Well, I have a field with the timestamp (date/time) and have a field with tickets numbers and I' trying to display the incident for each shift

Anonymous
Not applicable
Author

Thank you Pooja.

I'll try it

Anonymous
Not applicable
Author

it shows the morning shift correctly but the night shift is showing the tickets from 0 till 5 AM and from 5 PM till 12 of the same day which is not correct.

MarcoWedel

Hi,

I think former proposed solution meets you requirement to distinguish between morning and night shifts (you just asked for two buttons to do so).

Your requirement to distinguish between individual consecutive shifts is different from your initial question and might be implemented e.g. like this:

QlikCommunity_Thread_314445_Pic7.JPG

QlikCommunity_Thread_314445_Pic6.JPG

QlikCommunity_Thread_314445_Pic1.JPG

QlikCommunity_Thread_314445_Pic2.JPG

QlikCommunity_Thread_314445_Pic3.JPG

QlikCommunity_Thread_314445_Pic4.JPG

QlikCommunity_Thread_314445_Pic5.JPG

QlikCommunity_Thread_314445_Pic8.JPG

tabIncidents:

LOAD *,

    Dual(Shift&' '&ShiftDate, ShiftStart) as ShiftName;

LOAD *,

    DayName(ShiftStart) as ShiftDate,

    If(Time<'05:00' or Time>='17:00','Night','Morning') as Shift;

LOAD *,

    Time#(Time(Frac(DateTime),'hh:mm'),'hh:mm') as Time,

    Timestamp(Floor(DateTime,'12:00','05:00'),'MM/DD/YYYY hh:mm') as ShiftStart;

LOAD RecNo() as IncidentID,

    Timestamp#(Timestamp(Floor(Now()-Rand()*10,1,NORMINV(Rand(),'12:00','04:00')),'MM/DD/YYYY hh:mm'),'MM/DD/YYYY hh:mm') as DateTime

AutoGenerate 10000;

hope this helps

regards

Marco

Anonymous
Not applicable
Author

Thank you marcowedel

It's so impressive.

MarcoWedel

I'm glad you like it.

Please close your thread if your question is answered:

Qlik Community Tip: Marking Replies as Correct or Helpful

thanks

regards

Marco