Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
dirk_konings
Creator III
Creator III

Number of customers online each hour of the day

HI,

I have this data to read in QV:

CustomerDateFromTo
A02/01/20106:308:30
B02/01/20107:008:00
C02/01/20107:007:30
D02/01/20108:0010:30
E02/01/20108:008:15
F02/01/20108:009:15
G02/01/201010:0012:00


and i want to have a chart like this :

From - To# Customers
00:00 - 00:590
01:00 - 01:590
02:00 - 02:590
03:00 - 03:590
04:00 - 04:590
05:00 - 05:590
06:00 - 06:590,5
07:00 - 07:592,5
08:00 - 08:592,75
09:00 - 09:591,25
10:00 - 10:591,5
11:00 - 11:591
12:00 - 12:590


where each customer that is online a whole hour = 1

half hour = 0,5

What to do in the script for this ?? Is there a easy way ??

Thanks Dirk.

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Dirk,

if your data volume allows, you can generate hourly rows for each full or partial hour when the customer was active (based on a From-To range), and calculate the portion of the hour when the customer was online. See attached example.

best regards,

View solution in original post

4 Replies
Not applicable

Dirk,

take a look at 'intervalmatch' which should give you some ideas.

Regards,

Gordon

dirk_konings
Creator III
Creator III
Author

Gordon,

Don't think this will work. Intervalmatch is for 1 value between a min and max value.

In this case, i have to split every time into hour parts.

Dirk

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Dirk,

if your data volume allows, you can generate hourly rows for each full or partial hour when the customer was active (based on a From-To range), and calculate the portion of the hour when the customer was online. See attached example.

best regards,

Not applicable

Oleg

I used your example to split the time into the minutes between each hour segment as such

Stationary_time_split:

load

          RowID,

          hour(time(HourStart, 'hh:mm')) as HourID,

          time(HourStart, 'hh:mm') as HourStart,

          time(HourEnd, 'hh:mm') as HourEnd,

          num#(interval(time(rangemin([Vacated Time], HourEnd), 'hh:mm') - time(rangemax([Arrived Time], HourStart), 'hh:mm') , 'mm') ) as ActiveTime

;

load

          *,

          floor([Arrived Time], 1/24) + (Iterno() - 1)/24 as HourStart,

          floor([Arrived Time], 1/24) + (Iterno())/24  as HourEnd

resident Bay_Sensor_activity

while

          floor([Arrived Time], 1/24) + Iterno()/24 <= ceil([Vacated Time], 1/24) + 0.02 //

;

What i am struggling with though is if the TO date is different to the FROM date, i.e the time period extends past midnight into the following day.  I'm trying to amend the above to take account of the day and get it to generate the time through to the following day - however i'm struggling.  Any help on this would be very much appreciated

Thanks

Lewis