8 Replies Latest reply: Apr 28, 2014 1:37 PM by Rahul Lakhina RSS

    For Statement Optimization

    Rahul Lakhina

      Good Morning All,

       

      I have a QV document that uses a for loop to find a peak of all fields. I have more that 200 fields and am using the following script:

       

      Let vcount =NoOfFields('NewData')-3;

      trace $(vcount);

      FOR i=4 to 3+$(vcount)

      Let vname = '"' & FieldName(i ,'NewData') & '"';

      trace $(vname);

      if (i=4) then

       

      Test2:

      LOAD

      Key, Sale, VarValue_Time,    

      If(len(trim($(vname)))=0 and Key = Previous(Key), Peek($(vname)), $(vname)) As $(vname)

      Resident NewData Order by Key, Sale, VarValue_Time;

       

      ELSE

      join(Test2)

      LOAD Key, Sale, VarValue_Time,    

      If(len(trim($(vname)))=0 and Key = Previous(Key), Peek($(vname)), $(vname)) As $(vname)

      Resident NewData Order by Key, Sale, VarValue_Time;

      ENDIF

      NEXT;

       

      The script does exactly what I need it to do and does the job perfectly in the QVW attached, however when I run it on many days worth of data it runs out of memory.

       

      Is there any way to optimize this script so that it does not run out of memory?

       

      Any help would be hugely appreciated.

       

      Regards Rahul