Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Recommended way to count working people at set time slots

Hi,

I like to be able to count the numbers of persons working at spec time slots a day but I'm not sure whats the best way to handle the problem as most of my attempts feels clunky or wrong.

I have a table as shown below and I would like to be able to plot the number of people working ex at 10:00, 11:00 and 12:00 based on their start and end time.

IDStartEnd
108:0017:00
209:0023:00
307:1515:30
410:0012:00
119:0023:10

So, any recommendation how to address this issue?

1 Solution

Accepted Solutions
MarcoWedel

Hi,

one possible solution could be:

QlikCommunity_Thread_149043_Pic1_.JPG

tabWorkHours:

LOAD *

FROM [http://community.qlik.com/thread/149043] (html, codepage is 1252, embedded labels, table is @1);

tabTime:

LOAD Time((RecNo()-1)/24,'hh:mm') as Time

AutoGenerate 24;

tabLink:

IntervalMatch(Time)

LOAD Start, End Resident tabWorkHours;

hope this helps

regards

Marco

View solution in original post

8 Replies
Not applicable
Author

How about using

Class(Start,1) as the dimension

and Count(distinct ID) as the expression?

Or you can just do a floor on your time field and calculate the hour for each time. E.g 8:32am would become 8am

Colin-Albert

This technical brief has some examples that could be relevant to youGenerating Missing Data In QlikView

The example in the PDF for 'Creating a record for each day that a contract is valid'  is similar to your requirement, you just need to convert the time interval from days to hours.

Not applicable
Author

I have not looked into the class function for this, but i will give it a shoot to see if It might give me what Im looking for.

I dont have a date field at the table today (I can add one if required, no problem) but I can't see how that solves my problem at this time as the problem is not to get the time but to count the hours that at set between the start and end time.

MarcoWedel

Hi,

one possible solution could be:

QlikCommunity_Thread_149043_Pic1_.JPG

tabWorkHours:

LOAD *

FROM [http://community.qlik.com/thread/149043] (html, codepage is 1252, embedded labels, table is @1);

tabTime:

LOAD Time((RecNo()-1)/24,'hh:mm') as Time

AutoGenerate 24;

tabLink:

IntervalMatch(Time)

LOAD Start, End Resident tabWorkHours;

hope this helps

regards

Marco

Not applicable
Author

Thank you Colin,

I have looked at the example in the PDF and it works wonderfully when i use date but I cant get it to work with the time format I use in my starting post (hh:mm). also not sure what function to use instead or date (or if I should use date with formation flag).

Any idea?

Not applicable
Author

Hi and thank you Marco,

That is def an idea to try out and similar to what I had in mind when I started looking at the task and might be the way I choose. i will give it a go and see how it plays out with some more live data.

Thank you!

Colin-Albert

Hi Hampus,

Is your time field a text value e.g. 07:30 or is it a Qlikview time field created using time() or time#()?

If you add a test chart showing yourtimefield and num(yourtimefield) you can test this.

Not applicable
Author

In my test i just did was it just a inline field that was right aligned so I assume that it seen as a num field. However, have not double checked so its interpreted to correct time field.