Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Wint3rSt0rm
Contributor
Contributor

How to sort date columns

Hello,

I am new to Qlik and experiencing problems with sorting my date columns.

I have 2 date columns - MonthsSTR and YearsSTR

The values for the MonthsSTR one are : Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec.

The values for the YearSTR one are: 2019,2020,2021,2022

The auto sort is sorting them quite bad so I tried some wildmatch() functions and match() functions without much success.

Can anyone provide guidance or a solution for this?

Any help is appreciated

 

5 Replies
Aditya_Chitale
Specialist
Specialist

@Wint3rSt0rm   can you share what output are you currently getting ?

Regards,

Aditya

anat
Master
Master

Try using month number

num(MONTH(Date(SHPD_DT)))

Wint3rSt0rm
Contributor
Contributor
Author

Hello,

The output that i am getting is something like this:

Wint3rSt0rm_0-1647242926343.png

or this :

Wint3rSt0rm_1-1647242956930.png


or this - depending on selection from the date range picker:

Wint3rSt0rm_2-1647243026133.png

Cannot really find a pattern on how it arranges them as they sort of work at times and then they do not depending on selection. Often dont even get the same result with the same selection i have done a few selections in between the one that i am aiming to get the same results.

Wint3rSt0rm
Contributor
Contributor
Author

Hello,

Did try your suggestion. This did not affect the sorting in any way.
I am assuming this needs to go in the sorting section when i sort by expression and not in the data section where my dimension is ? correct?

Aditya_Chitale
Specialist
Specialist

Hi @Wint3rSt0rm ,

I assume that your Year dimension is sorting properly. Only issue is with months.

Try below sorting expression in "sort by expression" option of your month dimension:

pick(match(MonthsSTR,'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))

Also make sure other sorting options for month are unchecked.

 

Regards,

Aditya