2 Replies Latest reply: Oct 27, 2014 10:52 AM by Puttemans Johan RSS

    Select top/bottom 5 rows in script depending on variable

    Puttemans Johan

      Hi all,


      I have a file containing thousands of records that can be ordered following a given '% Key to MOAR' (KtM). Per individual KtM, there are still possibly hundreds of records/lines possible.

      I would like to cleanup the original file, and make sure that I end up per KtM with a maximum of 5 records/lines, based upon another variable in the set I created, being UniqueKey. Only the 5 lines that have the lowest(fastest) travel time should be selected per KtM. This is the first value in the UniqueKey variable. (notice in the example I need the UniqueKey measure for the top 5, as there is more than 1 train running in the same time between the selected KtM) I managed to create a variable that indicates how many lines per KtM need to be selected, as not all KtM have 5 lines (some have less, and they should then all be taken into account). The Traveltime variable is changing for every KtM, so working with a fixed number is impossible.


      Could anyone show me possible routes to a solution?


      Thank you