Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
jagan
Luminary Alumni
Luminary Alumni

Sorting the dates in x-axis

I have dates in the following format like

d-4 28-Jan

d-3 29-Jan

d-2 30-Jan

d-1 31-Jan

d0 1-Feb

d1 2-Feb

d2 3-Feb

How to arrange dates in this order in x-axis, i used both the sort by number and text, but the order is changed.

11 Replies
achiever_ajay
Contributor III
Contributor III

hi,

I think the problem here is you are not following a std format.. wat is de difference between

"d-1 and d1 "

"d-2 and d2"

as your data has differences. sorting is not working for you

Not applicable

You could use a dynamic dimension in which you conver the text strings to dates.

johnw
Champion III
Champion III

It sounds like your dates are actually text? If so, you could use a dual() function to assign an actual date value to them, something like:

dual('d' & num(Date-AnchorDate,'#,##0') & ' ' & date(Date,'DD-MMM'),Date) as RelativeDate,

You should then be able to sort them numerically.

Not applicable

Hello...I have a similar problem...

My x-axis is shows a TransMonthYear field (TransMonth & ' ' & TransYear as TransMonthYear ) this is how I want it to be displayed on the graph but is causing havoc with sorting the dates in the correct date order.

Will John's suggestion work for me? If so could someone explain it again for me as I couldn't follow the logic behind the statement 8-)

Many thanks!!! Mike

kji
Employee
Employee

If the data arrives in the correct order from your datasource, sort by "Load Order" could work.

Not applicable

Hi Johan... unfortunatly is doesn't come in such a nice order... Mike

Not applicable

Does anyone have any suggestions? Been trying all morning... Sad

johnw
Champion III
Champion III

date(makedate(TransYear,TransMonth),'MMM YYYY') as TransMonthYear // or whatever format you need for month and year

Not applicable

Thanks John... but still no joy... perhaps this might help...

These are the values in my TransYear and TransMonth fields

This is the new line in my load statement...

This loads ok but there when I look in the TransMonthYear field it is empty

Any other QlikTips?