1 Reply Latest reply: Jul 20, 2012 11:09 AM by Cesar Accardi RSS

    loop in script

      Dears,

      I have a file with script when I use many many times if function to compare dates and create a field.

      I am creating fields called '01.2011', '01.2012' etc based on a function e.g.

       

      if

      (pst.date >= '06.02.2011', 'n/a', if(status = 'open' or [clearing date] > '06.02.2011' or (pst.date <= '31.12.2010' and [clearing date] > '06.02.2011'),'X','-')) as [01.2011],

       

      Because i have such a line for every period from 2009-2012 I thought I could you maybe loop instead. However, I dont have idea how to do that.

       

      I attached a file with sample of three lines of such code and also the two source files.

      In tab v.3 I mapped all info from one table to another in case it is needed.

      Does anyone how to replace the if lines with loop?

       

      Thank you in advance

      justyna

        • Re: loop in script
          Cesar Accardi

          Hi,

           

          Have you checked if the dates you are using for comparison can't be obtained based on the current row you are reading for your table? Because loop structures in your script can increase the script execution time, so is best to avoid them...

           

          Anyway, if you are right to choose this path you can use something like this:

           

           

           

          FOR $(variable) = 0 to 1000

           

               LOAD

                    if(field > $(variable), ...)

               AUTOGENERATE(1);

           


          NEXT