2 Replies Latest reply: Mar 5, 2012 11:21 AM by mrpjspencer RSS

    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.

        • Re: Cant get nested 'if' statement to work.
          Miguel Angel Baeyens de Arce

          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

          • Re: Cant get nested 'if' statement to work.

            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