1 Reply Latest reply on Feb 14, 2009 12:02 AM by davidhead

    Identify when sorted field changes in table

    SeaQuest

      Title

      Identify when sorted field changes in table

      Post

      I have a simple table like this

       

      Student #      Course       Course Count        

      12345           Math 9        1

      12345           Eng 9          2

      12345           Sci 9          3

      23456           Math 9        1

      23456           Soc 9         2

      23456           Sci 9          3

      23456           PE 9           4

       

      The table is sorted by Student Number. I simply need to flag the last record for each student. Like this... 

       

      Student #      Course       Course Count     Flag

      12345           Math 9        1                     0

      12345           Eng 9          2                    0

      12345           Sci 9          3                     1

      23456           Math 9        1                     0

      23456           Soc 9         2                     0

      23456           Sci 9          3                     0

      23456           PE 9           4                     1

       

      The last record for each student is identified in the Flag field with 1, all other records are 0.

       

      Any suggestions? 

       

        • 1. Re: Identify when sorted field changes in table
          davidhead
            

          It could be done with a script that looped through all the records and set the field. The tip there would be to start from the last record and loop through to the first:

           

          Sort Records

          Go to Record/Request/Page [Last]

          Loop

            Set Field [Flag; If ( Student # = $id; 0; 1 )] 

            Set Variable [$id; Student #]

            Go to Record/Request/Page [Previous; Exit after last] 

          End Loop

           

          So that's how it could be done. Beware of record locking issues in a multi-user system.

           

          The next question would be why do you want to do that? I suspect that you may have some reason for flagging records that is part of your solution to some other problem. Did my last post work for you - the one about "average of students top marks"?