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: 
Anonymous
Not applicable

How to Sort Time bucket?

Hi All,

I have a trend line chart. and I would like to sort this chart by the time bucket filed which I created.

I calculate the Time Bucket field as follows:

Time(frac([Date]),'h tt') & ' - ' & Time(frac([Date]) + maketime(1,0,0),'h tt') as TimeBucket

How do I sort this field? so that it shows the data in the right format eg: 5 am - 6 am, 6 am - 7 am, 7 am - 8 am and so on.

1 Solution

Accepted Solutions
MarcoWedel

try to drag "TimeBucket" to position 1.

regards

Marco

View solution in original post

12 Replies
craigsutton
Creator
Creator

Can you sort my expression =[Date]?

Anonymous
Not applicable
Author

Yes I tried. Its giving the same result. Its not sorting

OmarBenSalem

Can you share your sample app?

So that we can perform tests?

It will be more helpful if we have the actuals dates to work with.

MarcoWedel

Dual(Time(Frac(Date),'h tt') & ' - ' & Time(Frac(Date) + MakeTime(1,0,0),'h tt'), Hour(Date)) as TimeBucket

Dual(Time(Date,'h tt')&' - '&Time(Date+'01:00','h tt'), Hour(Date)) as TimeBucket

sorting numerically

hope this helps

regards

Marco

Edit: shorter expression without unnecessary Frac() function when creating the text part of the dual-values.

MarcoWedel

Hi,

one example:

QlikCommunity_Thread_255613_Pic1.JPG

table1:

LOAD *,

    Dual(Time(Date,'h tt')&' - '&Time(Date+'01:00','h tt'), Hour(Date)) as TimeBucket;

LOAD Timestamp(Now()-Rand()*100) as Date

AutoGenerate 100;

hope this helps

regards

Marco

Anonymous
Not applicable
Author

Hi Marco,

I tried using the dual function in my load script

and sorting the data numerically:

I am still getting the same result. Its not sorting yet.

Can you tell me where am I going wrong?

MarcoWedel

try to drag "TimeBucket" to position 1.

regards

Marco

Anonymous
Not applicable
Author

Great!. It works. I am very new to Qliksense and thank you so much for your inputs. What is the significance of moving the field to position1?

MarcoWedel

changing the position rearranges the sorting order:

Change the sorting of a visualization

hope this helps

regards

Marco