Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
sri94aa
Contributor
Contributor

Count the number of Calls made in a particular hour - Set Analysis

Hello,

I wanted to get the total count of calls made by the REST API, in a particular time frame. Eg:

Say I am doing 2 REST API Calls at 12:40:00 & 12:56:00 and 4 Rest API calls between 3pm-4pm, I need to get the below:

Time Frame Count
12pm-1pm 2
1pm-2pm 0
2pm-3pm 0
3pm-4pm 4
Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The built in function to split into buckets is Class(). 

Class(CallTimestamp, Interval#(1,'h'))

Sometimes people write the width argument as "1/24" instead of "Interval#(1,'h')".  I think "Interval#()" is more correct.  You can also use "MakeTime(1)".

However Class() won't give the string formatting you asked for so I would write it as:

Time(Floor(CallTimestamp, Interval#(1,'h')), 'htt')
& '-'
& Time(Ceil(CallTimestamp+.000001, Interval#(1,'h')), 'htt')

Meaning round down to hour with Floor and round up to next hour with Ceil.  The +.000001 is necessary to handle the case where CallTimestamp is exactly on the hour. 

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

View solution in original post

5 Replies
Chanty4u
MVP
MVP

Try this modify according to your time frame

=if(hour(CallTimestamp) >= 12 and hour(CallTimestamp) < 13, '12pm-1pm',

  if(hour(CallTimestamp) >= 13 and hour(CallTimestamp) < 14, '1pm-2pm',

  if(hour(CallTimestamp) >= 14 and hour(CallTimestamp) < 15, '2pm-3pm',

  if(hour(CallTimestamp) >= 15 and hour(CallTimestamp) < 16, '3pm-4pm', 'Other')

)))

sri94aa
Contributor
Contributor
Author

We don't have any built-in functions to split for 24 hours?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The built in function to split into buckets is Class(). 

Class(CallTimestamp, Interval#(1,'h'))

Sometimes people write the width argument as "1/24" instead of "Interval#(1,'h')".  I think "Interval#()" is more correct.  You can also use "MakeTime(1)".

However Class() won't give the string formatting you asked for so I would write it as:

Time(Floor(CallTimestamp, Interval#(1,'h')), 'htt')
& '-'
& Time(Ceil(CallTimestamp+.000001, Interval#(1,'h')), 'htt')

Meaning round down to hour with Floor and round up to next hour with Ceil.  The +.000001 is necessary to handle the case where CallTimestamp is exactly on the hour. 

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

sri94aa
Contributor
Contributor
Author

Thank you let me try and post the results here.

sri94aa
Contributor
Contributor
Author

This worked! thanks a lot  @rwunderlich.