Discussion Board for collaboration on QlikView Scripting.
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 ?
Go to Solution.
You can create a dual for this, and sort it numerically, like this.
Dual(Right(Year(date), 2), YearStart(date))
Simply because year is now traited as Text o String format. Format your year using Date() function to retain it as Year. See line of script below:
Date(date,'YY') as [year_]
It is very important to keep year in it's original format. Hope it helps.
Also, to not change your original script, please see image below:
i get duplicated year. any work around ?
Instead of this script
Right(year(date),2) as [year_], -- Right() will give you the result in string
you use this
Date(date, 'YY') as [year_] this will give you the year in date (numeric)
Hope this helps you.
You can try it in he script as well.
hi paul may i know why you use like that
I am lazy to write code for year field :-
IF(year= '1997' ,'97',
IF(year= '1998' ,'98',
IF(year= '1999' ,'99',
IF(year= '2000' ,'00',
IF(year= '2001' ,'01',
IF(year= '2002' ,'02',
IF(year= '2003' ,'03',
IF(year= '2004' ,'04',
IF(year= '2005' ,'05',
IF(year= '2006' ,'06',
IF(year= '2007' ,'07',
IF(year= '2008' ,'08',
IF(year= '2009' ,'09',
IF(year= '2011' ,'11',
IF(year= '2012' ,'12',
if i use :-
My year field unable to sort like below :-
98 99 10 11
Notice that it not able to sort . i need it :-
96 99 00 11 12