1 Reply Latest reply: Sep 14, 2018 9:24 AM by Michael Sikora RSS

    if condition

    Bharat Kishore

      Hi all,

       

      i have the below code in script

       

      LOAD

           Key_EMS,

           If(Scenario_Type='Consumption', date(Max(Movement_Date),'YYYY-MM')) AS Install_Date,

           If(Scenario_Type='Defective',   date(Max(Movement_Date),'YYYY-MM')) AS Removal_Date

       

      resident Master_Final

      group by Key_EMS;


      Now i need to pass one more condition in If(Scenario_Type='Defective',   date(Max(Movement_Date),'YYYY-MM')) as Removal_Date,


      the condition what i need to pass is the below one


      if(Removal_Date>Install_Date,'-',Removal_Date)


      Can you please tell me how to achieve  it.


      Thanks,

      Bharat

        • Re: if condition
          Michael Sikora

          Bharat,

           

          Try doing the following:

           

          Table:

          LOAD

               Key_EMS,

               If(Scenario_Type='Consumption', date(Max(Movement_Date),'YYYY-MM')) AS Install_Date,

               If(Scenario_Type='Defective',   date(Max(Movement_Date),'YYYY-MM')) AS Removal_Date

           

          resident Master_Final

          group by Key_EMS;


          Left Join(Table)

          LOAD

               Key_EMS,

               if(Removal_Date>Install_Date,'-',Removal_Date);

          resident Table

          Group BY Key_EMS;