LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Number range grouping

    Employee
    Posted 08-18-2014 03:26

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: aop

    Hi!

    Looking for help with configuring filter and do output statment. Any help would be appreciated!

    My input data has two columns (named group and number) and the data is sorted by group and number. Number field contains running numbering sequence that might also have some gaps in the sequence.

    Example of the data:
    group,number
    A,1000
    A,1001
    A,1002
    A,1008
    B,5123
    B,5124
    B,5129

    I would need an output like the following:
    group,start,end
    A,1000,1002
    A,1008,1008
    B,5123,5124
    B,5129,5129

    I would need to achieve the following things:
    -Step1: Group the input data so that each continous sequence (without gaps) belonging to a same group would be one line in the output with fields indicating the first and last number in the continous sequence. When there is a gap a new line in the output would be created
    -Step2: I also have an additional requirement that the maximum length of one sequence in the output is 10 (including first and last) so for example if there is 11 numbers in a continous sequence then the the 11th number would be on another line in the output.


  • 2.  RE: Number range grouping

    Employee
    Posted 08-18-2014 11:01

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    See attached. I broke this up into three steps. The first one (AggEx) is to group all the consecutive numbers together. I create a new field called "FirstNum" so I can use that to group in the second step. This first step outputs the same number of records as the input. The second step (AggEx) further groups with the "FirstNum" field so you only get the number of buckets you want. The final step is to make things pretty with a Filter, mostly a list manipulation exercise. You could combine the second and third steps, but broken out here for ease of following.
    Attachments:
    range_grouping.brg