Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

time interval

Hi all,

I have a problem that is starting to look a little impossible 😞

I have a table box that shows a list of activities by time  :

First nameLast NameTimeDateActivity
JohnDoe08:57:2721/01/2013Arrived at Work
JohnDoe08:58:5721/01/2013Did something 0
JohnDoe08:59:2421/01/2013Did something 1
JohnDoe09:01:1921/01/2013Did something 2
JohnDoe09:05:3121/01/2013Lunch Start
JohnDoe09:49:4121/01/2013Did something 4
JohnDoe09:53:4421/01/2013Lunch Finish
JohnDoe10:43:4521/01/2013Did something 6
JohnDoe10:48:2321/01/2013Did something 7
JohnDoe12:23:4021/01/2013Did something 8
JohnDoe12:27:0721/01/2013Went Home

I need to find how long the person was on lunch.

The interval between Activity 'Lunch Start' and 'Lunch Finish'

It would be great if i could display the time spent on lunch in a seperate text box.

Any Ideas ??

Thanks

Martin

5 Replies
Nicole-Smith

Check attached example.

swuehl
MVP
MVP

You want just a text box for John?

Maybe like this:

='Lunch time John spent: ' & interval(sum(aggr(

only({<Activity= {'Lunch Finish'}, [Last Name] = {Doe},[First Name]= {John}>} Time) -

only({<Activity= {'Lunch Start'}, [Last Name] = {Doe},[First Name]= {John}>} Time)

, Date)))

which takes care for multiple lunch breaks on multiple Dates that needs to be summed. (Or just

='Lunch time John spent: ' & interval(

only({<Activity= {'Lunch Finish'}, [Last Name] = {Doe},[First Name]= {John}>} Time) -

only({<Activity= {'Lunch Start'}, [Last Name] = {Doe},[First Name]= {John}>} Time)

)

if you don't need to take care of that).

See also attached.

Regards,

Stefan

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

=TimeStamp(Timestamp#(max({<Activity={'Lunch Finish'}>} Date) & ' ' &max({<Activity={'Lunch Finish'}>} Time), 'dd/MM/yyyy hh:mm:ss') -

Timestamp#(max({<Activity={'Lunch Start'}>} Date) & ' ' &max({<Activity={'Lunch Start'}>} Time), 'dd/MM/yyyy hh:mm:ss'), 'hh:mm')

Hope this helps you

Regards,

Jagan.

Not applicable
Author

Hi,

Thanks for your reply !

It works great appart from when the data has multiple lunch times :

First nameLast NameTimeDateActivity
JohnDoe08:57:2721/01/2013Arrived at Work
JohnDoe08:58:5721/01/2013Did something 0
JohnDoe08:59:2421/01/2013Did something 1
JohnDoe09:01:1921/01/2013Did something 2
JohnDoe09:05:3121/01/2013Lunch Start
JohnDoe09:49:4121/01/2013Did something 4
JohnDoe09:53:4421/01/2013Lunch Finish
JohnDoe10:43:4521/01/2013Did something 6
JohnDoe10:44:0021/01/2013Lunch Start
JohnDoe10:48:2321/01/2013Did something 7
JohnDoe12:00:0021/01/2013Lunch Finish
JohnDoe12:23:4021/01/2013Did something 8
JohnDoe12:27:0721/01/2013Went Home

Then i just get 00:00:00

If you have any ideas on how to fix this it would be fantastic !!

Thanks for all your help 🙂

Martin

swuehl
MVP
MVP

That's because there is no unambiguous answer for the lunch timestamps when evaluating the suggested only() expression, looking at that given date.

Maybe you can calculate the lunch time intervals already in the script, please check attached sample.