Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Cant get nested 'if' statement to work.

if(Created_On=>'2010-04-01' or Created_On<='2011-03-31','10/11',

if(Created_On=>'2011-04-01' or Created_On<='2012-03-31','11/12')) as COD

Qlikview tells me

Error in expression:

')' expected

TABLE_1:

LOAD if(Created_On=>'2010-04-01' or Created_On<='2011-03-31','10/11',

     if(Created_On=>'2011-04-01' or Created_On<='2012-03-31','11/12')) as COD

Why is this when im clearly not missing any parenthesis?

Paul.

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi Paul,

The greater than or equal to operator is ">=" instead of "=>"

Data:

LOAD *,

     If(Date(Date#(Created_On, 'DD.MM.YYYY')) >= Date(Date#('01.04.2010', 'DD.MM.YYYY')) AND Date(Date#(Created_On, 'DD.MM.YYYY')) <= Date(Date#('31.03.2011', 'DD.MM.YYYY')), '10/11',

     If(Date(Date#(Created_On, 'DD.MM.YYYY')) >= Date(Date#('01.04.2011', 'DD.MM.YYYY')) AND Date(Date#(Created_On, 'DD.MM.YYYY')) <= Date(Date#('31.03.2012', 'DD.MM.YYYY')), '11/12')) AS COD

INLINE [

ID, Name, Created_On

1, AAA, 15.02.2011

2, BBB, 12.01.2012

];

Hope that helps.

Miguel

View solution in original post

2 Replies
Miguel_Angel_Baeyens

Hi Paul,

The greater than or equal to operator is ">=" instead of "=>"

Data:

LOAD *,

     If(Date(Date#(Created_On, 'DD.MM.YYYY')) >= Date(Date#('01.04.2010', 'DD.MM.YYYY')) AND Date(Date#(Created_On, 'DD.MM.YYYY')) <= Date(Date#('31.03.2011', 'DD.MM.YYYY')), '10/11',

     If(Date(Date#(Created_On, 'DD.MM.YYYY')) >= Date(Date#('01.04.2011', 'DD.MM.YYYY')) AND Date(Date#(Created_On, 'DD.MM.YYYY')) <= Date(Date#('31.03.2012', 'DD.MM.YYYY')), '11/12')) AS COD

INLINE [

ID, Name, Created_On

1, AAA, 15.02.2011

2, BBB, 12.01.2012

];

Hope that helps.

Miguel

Not applicable
Author

Yes that worked! Thankyou!

I had to make minor modification to it to accomodate for the American date system like so :-

If

(Date(Date#(Created_On, 'YYYY-MM-DD')) >= Date(Date#('2010.04.01', 'YYYY-MM-DD')) AND

If(Date(Date#(Created_On, 'YYYY-MM-DD')) >= Date(Date#('2010.04.01', 'YYYY-MM-DD')) AND Date(Date#(Created_On, 'YYYY-MM-DD')) <= Date(Date#('2011.03.31', 'YYYY-MM-DD')), '10/11',

If(Date(Date#(Created_On, 'YYYY-MM-DD')) >= Date(Date#('2011.04.01', 'YYYY-MM-DD')) AND Date(Date#(Created_On, 'YYYY-MM-DD')) <= Date(Date#('2012.03.31', 'YYYY-MM-DD')), '10/12')) AS COD