Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

paulyeo11
Valued Contributor II

How to make my year field easy maintenance ?

Hi All

My Year field , i need to add below script :-

=IF(year='2013','13',

IF(year= '2014' ,'14',

IF(year= '2015' ,'15',

IF(year= '2016' ,'16',

IF(year= '2017' ,'17',

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(year= '2010','10'))))))))))))))))))

My issue is every year i need to amend/edit the above script by add =if(year='2018','18',

it there any way i can make it automatic ? Dont need edit the script yearly ?

Paul

1 Solution

Accepted Solutions
sdmech81
Valued Contributor

Re: How to make my year field easy maintenance ?

HI ,

Put expression like:

=If(year>=2004,Right(year,2))

find attachment

Sachin

8 Replies
paulyeo11
Valued Contributor II

Re: How to make my year field easy maintenance ?

my QVW

rahulpawarb
Valued Contributor II

Re: How to make my year field easy maintenance ?

Hello Paul,

You can make use of below expression:

=Right(year,2)

Regards!

Rahul

paulyeo11
Valued Contributor II

Re: How to make my year field easy maintenance ?

Hi Sir

Your approach work fine.

Now i want to year start from 2004 till current year.

May i know how to make not display year before 04 ?

Paul

dsharmaqv
Contributor III

Re: How to make my year field easy maintenance ?

Use below

=Date(Date#(year,'YYYY'),'YY')

Using this you will allow you to sort and perform calculation without any issue.

paulyeo11
Valued Contributor II

Re: How to make my year field easy maintenance ?

Hi Deepak

Mr Rahul solution is correct because it able to sort.

Paul

sdmech81
Valued Contributor

Re: How to make my year field easy maintenance ?

HI ,

Put expression like:

=If(year>=2004,Right(year,2))

find attachment

Sachin

sdmech81
Valued Contributor

Re: How to make my year field easy maintenance ?

Hope this is what u wanted

U can alter year as u need ..

Sachin

paulyeo11
Valued Contributor II

Re: How to make my year field easy maintenance ?

Hi Sachin

thank you very much it work fine.

Paul