Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

2 digit year field how to sort from hi to lo ?

Hi All

I am using below code to get 2 digit for year :-

  Right(year(date),2)           as [year_],

I am not able to sort the year in sequences from hi to lo

Any work around ?

PAul

18 Replies
Not applicable
Author

why dont you use right(year(date),2) as Year

tresesco
MVP
MVP

In the sort tab->Expression

=Year

jonathandienst
Partner - Champion III
Partner - Champion III

Paul

You can create a dual for this, and sort it numerically, like this.

Dual(Right(Year(date), 2), YearStart(date))

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi tres

I add sort expression as you said. but still not sort as my wish.

karthickv
Partner - Creator
Partner - Creator

Once you sort it by 'Year' field , it works like expected .

Date Sort.png
My Advice would be rather than writing a big "IF" expression in the front end (In the list Year list box), it would be great if would get this done from the Backend Script to have a better performance .

Regards,

Karthick V

tresesco
MVP
MVP

I see it fine !

Untitled.png

Sokkorn
Master
Master

Mr. Paul,

I know this post closed already. Just want to add new idea with below script for simple function and better performance

Date(YearStart([DateField]),'YY')     AS [Years]

Above function will sort order automatically.

Regards,

Sokkorn

Not applicable
Author

Hi All

Many thank. Now i found more then 3 people provide the right solution. I must said Jona get it right first.

Not applicable
Author

yes your also correct.