Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
DamianoD
Contributor II
Contributor II

Sorting X Axis on Bar Chart not working properly

Hello everyone,

I'm stuck with a minor problem which i can't get through.

I have this expression that calculates difference in hours between two fields and convert them in integer datatype:

Num(Num#(Interval(Date(Date#(flight_operative_date,'YYYY-MM-DD hh:mm:ss'),'YYYY-MM-DD hh:mm:ss')-Date(Date#(create_reservation,'YYYY-MM-DD hh:mm:ss'),'YYYY-MM-DD hh:mm:ss'),'hh')))

When i use this dimension along with a measure in a bar chart, the sort numerically, as well as sort by expression, do not work.

DamianoD_0-1727943632740.png

 

Any suggestion?

Labels (2)
1 Reply
hic
Former Employee
Former Employee

It's impossible to say without seeing your sort settings. But I would start by simplifying the expression, that contains multiple interpretations and formattings, and that could cause the problem.

First, you should make sure that the timestamps are correctly interpreted in the script:
TimeStamp#(flight_operative_date,'YYYY-MM-DD hh:mm:ss') as flight_operative_date,
TimeStamp#(create_reservation,'YYYY-MM-DD hh:mm:ss') as create_reservation,


Then you can use the following, that will give the answer in hours and minutes:
Interval(flight_operative_date-create_reservation,'hh:mm:ss')

or if you want it in decimal hours:
Num(24*(flight_operative_date-create_reservation),'#0.00','.',',')