Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
DJ21
Contributor
Contributor

How can we sort with String value "JAN-22 to JUN-22" by expression in Qlik?

Wanted to create line graph with monthly analysis of data with MMM-YY but it is not working with. Kindly help to sort data with expression in Qlik.

JAN-22, FEB-22, MAR-22, APR-22, MAY-22, JUN-22

Labels (1)
1 Solution

Accepted Solutions
Sujy15
Contributor II
Contributor II

Hi @DJ21 ,

If your primary sorting is based on "Timeline" field contains (MMM-YY) then try using the expression given by @kaushiknsolanki  in Sorting section.

Sorting - > Custom (Sorting) - > check Sort by expression - > and give the expression as Date(Date#(FieldName,'MMM-YY'))

Sample Data Output:

Sujy15_0-1655790587314.png

Hope it may helps you!

Thanks!

View solution in original post

8 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Convert the text into the dates and then sorting will happen automatically.

Try the below expression in the script.

Date(Date#(FieldName,'MMM-YY')) as New_FieldName

 

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
DJ21
Contributor
Contributor
Author

File Qlik 2.jpg

File Qlik.jpg

  

DJ21
Contributor
Contributor
Author

This solution is not working

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

This has to be written in the script editor and not in the chart expression.

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
DJ21
Contributor
Contributor
Author

Hello, Thank you for clarification.
But How to write in script editor. Please find screen shot. This is showing error.

Qlik chart.jpg

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

It has to be in the load statement and not as a variable. from where is your TImeline field coming?

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
DJ21
Contributor
Contributor
Author

Not working. Please find data load new column.

Qlik chart 2.jpg

Sujy15
Contributor II
Contributor II

Hi @DJ21 ,

If your primary sorting is based on "Timeline" field contains (MMM-YY) then try using the expression given by @kaushiknsolanki  in Sorting section.

Sorting - > Custom (Sorting) - > check Sort by expression - > and give the expression as Date(Date#(FieldName,'MMM-YY'))

Sample Data Output:

Sujy15_0-1655790587314.png

Hope it may helps you!

Thanks!