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: 
johnnyjohn
Creator
Creator

Group data in table by hour

I have the following data

johnnyjohn_0-1587551860823.png

 

I would like to create a bar chart that group the timestamp by hour and sums the qty_traded in that hour. Currently I just display the data from the table above raw (see below), and I am not sure how to achieve this grouping by hour, so that I have much less bars.

johnnyjohn_1-1587551997452.png

Help would be greatly appreciated. 

Thanks

Labels (2)
3 Replies
balabhaskarqlik

Try this:

Table1:
Load
time,
Left(time,2) as Timestamp,
qty_traded
from abc;

noconcatenate

Table2:
Load
Timestamp,
Sum(qty_traded) as total_qty
Resident Table1
group by Timestamp;

Drop table Table1;

johnnyjohn
Creator
Creator
Author

@balabhaskarqlik thank you for your reply.

I had thought there would be a general solution to do that for different time intervals, but using this method it seems not.

Can this be done for half hours intervals, e.g. 09:00, 09:30, 10:00, 10:30?

Thanks!

tresesco
MVP
MVP

You could use class() in calculated dimension expression (or in script) like:

=Time(SubField(replace(Class(Time, 30/(24*60)), '<= x <','|'), '|',1))
& '-' &
Time(SubField(replace(Class(Time, 30/(24*60)), '<= x <','|'), '|',2))

Capture.PNG