4 Replies Latest reply: Apr 7, 2015 1:02 PM by John McNamara RSS

    Load Script Question - Populate number groups



      I have the below requirement, any suggestions on how I could do this in the load script?



      For the same ID I need to create a new field which contains numbers starting from 1 and grouping by the GroupCount value (ex) the first GroupCount value is 3 so we populate the first 3 rows with 1, the second GroupCount value is 2 so we populate the next 2 rows with 2 etc...


      Any help would be appreciated.

        • Re: Load Script Question - Populate number groups
          anbu cheliyan
          Load *,AutoNumber(RowNo(),ID) As Result;
          Load * Inline [
          TEST1,4 ];
          Load *,RowNo() Resident Temp While IterNo() <= GroupCount;
          Drop Table Temp;
            • Re: Load Script Question - Populate number groups

              Hi Anbu,


              Thanks for the above script! This script is very close to solving my issue but I spotted an issue with it. I've added a new field, Cost, below to highlight what happens when I run the script.



              So the script does create the field 'Desired Result' as requested but in doing so it replicates the data in the first 3 rows (ie) all of the data from row 1 appears three times in the output data, row 2 appears twice, etc...


              What I'm after is the column 'Desired Result' but with no other changes to the existing data, so in this case Cost would remain unchanged (Desired Cost) rather than end up like the 'Current Cost' field.


              I hope this makes sense and thanks again for picking this up!