Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I need help on a utilization calculation that I am working on.
I am trying to calculate utilization per hour for an imaging scanner. My issue is calculating utilization per hour over the year and I would like to add a ceiling of 120mins for exams over 2hours. I saw another example but it is not exactly what I am looking for. I don't know how to start so any help would be great.
Start_time End_time Duration 7am 8am 9am 10am
1/1/17 7:30am 1/1/17 8:30am 60mins 30mins 30mins
1/1/17 8:45am 1/1/10 9:30am 90mins 15mins 30mins
Please let me know if you need more information.
Thanks,
Kurleigh
Maybe start with something like this, use BucketHour and DurationBucket to create your statistics:
Set TimestampFormat = 'M/D/YY h:mmtt';
INPUT:
LOAD Recno() as RecID, *, Round((End_time -Start_time)*(60*24)) as Duration INLINE [
Start_time, End_time
1/1/17 7:30am, 1/1/17 8:30am
1/1/17 8:45am, 1/1/17 9:30am
];
LOAD RecID,
Iterno() as BucketID,
Hour(Start_time+(iterno()-1)*MakeTime(1)) as Bucket_Hour,
Round(
(RangeMin(End_time,Ceil(Start_time+(iterno()-1)*MakeTime(1), MakeTime(1)))
-RangeMax(Start_time,Floor(Start_time+(iterno()-1)*MakeTime(1), MakeTime(1))))
*60*24) as DurationBucket
Resident INPUT
WHILE Start_time+(iterno()-1)*MakeTime(1) <= Ceil(End_time,MakeTime(1));
Thanks Stefan,
I'll give it a try and let you know how it works out.
Kurleigh
Hi Stephan,
I am finding that my durations are not lining up correctly with the start time end time. Can you point out where this is happening? I loaded a few more time stamps
Set TimestampFormat = 'M/D/YY h:mmtt';
INPUT:
LOAD Recno() as RecID, *, Round((End_time -Start_time)*(60*24)) as Duration INLINE [
Start_time, End_time
1/1/17 9:45am, 1/1/17 10:00am
1/1/17 10:15am, 1/1/17 12:30pm
1/1/17 1:45pm, 1/1/17 2:45pm
1/1/17 3:15pm, 1/1/17 5:00pm
1/1/17 5:41pm, 1/1/17 6:23pm
1/1/17 7:15pm, 1/1/17 10:30pm
];
LOAD RecID,
Iterno() as BucketID,
Hour(Start_time+(iterno()-1)*MakeTime(1)) as Bucket_Hour,
Round(
(RangeMin(End_time,Ceil(Start_time+(iterno()-1)*MakeTime(1), MakeTime(1)))
-RangeMax(Start_Time,Floor(Start_time+(iterno()-1)*MakeTime(1), MakeTime(1))))
*60*24) as DurationBucket
Resident INPUT
WHILE Start_time+(iterno()-1)*MakeTime(1) <= Ceil(End_time,MakeTime(1));
After correcting the incorrect field name spelling (Start_Time instead of Start_time), this is what the script returns:
RecID | Duration | Start_time | End_time | Bucket_Hour | BucketID | DurationBucket |
1 | 15 | 1/1/17 9:45am | 1/1/17 10:00am | 9 | 1 | 15 |
2 | 135 | 1/1/17 10:15am | 1/1/17 12:30pm | 10 | 1 | 45 |
2 | 135 | 1/1/17 10:15am | 1/1/17 12:30pm | 11 | 2 | 60 |
2 | 135 | 1/1/17 10:15am | 1/1/17 12:30pm | 12 | 3 | 30 |
3 | 60 | 1/1/17 1:45pm | 1/1/17 2:45pm | 13 | 1 | 15 |
3 | 60 | 1/1/17 1:45pm | 1/1/17 2:45pm | 14 | 2 | 45 |
4 | 105 | 1/1/17 3:15pm | 1/1/17 5:00pm | 15 | 1 | 45 |
4 | 105 | 1/1/17 3:15pm | 1/1/17 5:00pm | 16 | 2 | 60 |
4 | 105 | 1/1/17 3:15pm | 1/1/17 5:00pm | 17 | 3 | 0 |
5 | 42 | 1/1/17 5:41pm | 1/1/17 6:23pm | 17 | 1 | 19 |
5 | 42 | 1/1/17 5:41pm | 1/1/17 6:23pm | 18 | 2 | 23 |
6 | 195 | 1/1/17 7:15pm | 1/1/17 10:30pm | 19 | 1 | 45 |
6 | 195 | 1/1/17 7:15pm | 1/1/17 10:30pm | 20 | 2 | 60 |
6 | 195 | 1/1/17 7:15pm | 1/1/17 10:30pm | 21 | 3 | 60 |
6 | 195 | 1/1/17 7:15pm | 1/1/17 10:30pm | 22 | 4 | 30 |
could you point to the issue?
Hello,
First of all thank you for this script!
But, I need to show all the hours even if there is no transaction...
Do you know how can I done that?
Regards