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.  Declare Max value from a list as a variable within a Filter node

    Employee
    Posted 04-12-2016 21:45

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

    Originally posted by: dglavastorm

    Hi

    I need have two datasets joining together with a sequential Unique Key field in one but not the other.

    I need to create the Unique Keys for the second dataset, but to do that I first need to know what the max value of the Unique Key is in the first dataset so I can sequentially generate the new Unique Keys.

    I can't find any code to do this. I can use the Tail node to find the max value, but that won't help as I need to use the max value as a variable to generate the new keys, not create a new field.

    I can't even do a join to bring this field in as there is nothing to join on.

    Generating the key is with the below code, I just need to know how to find the max value in the existing data and use it in a formula, replacing the P_Key = 0 with P_Key = Max value from previous dataset.

    if firstInGroup then P_KEY = 0
    P_KEY = P_KEY + 1

    Example data attached.

    Cheers,

    Dave
    Attachments:
    max value.zip


  • 2.  RE: Declare Max value from a list as a variable within a Filter node

    Employee
    Posted 04-13-2016 05:53

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

    Originally posted by: ryeh

    See attached. There are two variations. If the records are already in order, with keys in the first group ascending followed by the second group (with no keys), then it's pretty easy. If not, it's a bit more complicated as you need to determine the maximum value.
    Attachments:
    addKeys.brg


  • 3.  RE: Declare Max value from a list as a variable within a Filter node

    Employee
    Posted 04-13-2016 07:59

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

    Originally posted by: ltolleson

    Hi Dave,

    I added one other option to the great examples that Roger has already given. I think this is what you were trying to do with the Tail node.

    See Attached Graph...

    Thanks,
    Larry
    Attachments:
    addKeys.brg


  • 4.  RE: Declare Max value from a list as a variable within a Filter node

    Employee
    Posted 04-18-2016 07:54

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

    Originally posted by: dtigue

    Hi Dave,

    To bring the field calculated using the tail, you could do a join.
    Instead of having a field to join on you can place the number 1 in both the LeftInputKey and RightInputKey - creates a cartesian product.
    Then to get your unique key would be MaxUniqueValue + execCount

    Hope this helps


  • 5.  RE: Declare Max value from a list as a variable within a Filter node

    Employee
    Posted 05-01-2016 16:59

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

    Originally posted by: dglavastorm

    Done, thanks everyone :-)