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: 
adias102
Contributor III
Contributor III

Count ID for each hour (for ex. number of employees in the office by the hour)

Hi,

I need to create a Pivot table that shows how many employees are at the office by day of week and hour, regardless of the month and year. That is, empA arrived at 01/01/2021 20:35 and left at 02/01/2021 09:05 (dd/mm/yyyy hh:mm) so I need to see that for each hour between friday at 20:00 and saturday at 10:00 there was 1 employee at the office.

My data is basically:
EmpID             123
StartTime       01/01/2021 20:35:00.000
EndTime         02/01/2021 09:05:00.000
and the rest of the information....

For each employee i have the attendance time for the last few years.
Since we are a 24/7 organiztaion, the time between StartTime and EndTime can be over 24h.
For example: StartTime 04/04/2021 08:00, EndTime 06/04/2021 09:00 (dd/mm/yyy hh:mm) and I need to see 1 employee at the office from sunday at 08:00 untill tuesday at 09:00.

 

  day of week
from hourto hourSundayMondayTuesdayWednesdayThursdayFridaySaturday
00:0001:00      1
01:0002:00      1
02:0003:00      1
03:0004:00      1
04:0005:00      1
05:0006:00      1
06:0007:00      1
07:0008:00      1
08:0009:00      1
09:0010:00      1
10:0011:00       
11:0012:00       
12:0013:00       
13:0014:00       
14:0015:00       
15:0016:00       
16:0017:00       
17:0018:00       
18:0019:00       
19:0020:00       
20:0021:00     1 
21:0022:00     1 
22:0023:00     1 
23:0000:00     1 

 

I would appreciate any suggestions.

 

 

 

 

1 Solution

Accepted Solutions
Dalton_Ruer
Support
Support

You need to use the IntervalMatch function, this will jump to help for it. 

I have attached an application that demonstrates it with example of minute by minute analysis, and it needs the Master Calendar QVD that the other application generates. But you can just copy the code out of the minute calendar application instead of generating the QVD if you wish. The simply change it to be hourly instead. 

View solution in original post

2 Replies
Dalton_Ruer
Support
Support

You need to use the IntervalMatch function, this will jump to help for it. 

I have attached an application that demonstrates it with example of minute by minute analysis, and it needs the Master Calendar QVD that the other application generates. But you can just copy the code out of the minute calendar application instead of generating the QVD if you wish. The simply change it to be hourly instead. 

adias102
Contributor III
Contributor III
Author

Thank you, it was very helpful 🙂