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.  reduce to list of distinct values from field "listed"

    Employee
    Posted 10-17-2012 04:37

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

    Originally posted by: Gloria

    I'm using the "reduce to list" node, and getting a list of all values in the ItemField, which includes duplicates. Is there a predicate expr or some other means of limiting the listed values to just one instance of each value (i.e., list distinct)? The SORT Unique function won't work for this, because of the variables involved.

    Also, need to have a count of the number of distinct values in the list.

    For example, the 4 DS0QTY USOCs found on the DS0 Acct ETNs listed all point to the same DS1 CLS. How can I get the output to show 2 DS0 Accts, and give me an output field that provides 2 as the count of DS0 Accts in the list? (The list could contain up to 24 unique acct numbers.)

    DS0Qty DS1 CLS DS0 Acct-list
    4 50.DHMM.123456..SB *478U401234567*478U407654231*478U401234567*478U407 654231*


  • 2.  RE: reduce to list of distinct values from field "listed"

    Employee
    Posted 10-19-2012 08:43

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

    Originally posted by: rboccuzzi

    Here is an example that might help. Actually, it is three examples.

    The first one uses the (hidden) knowledge of how the Reduce-To-List node, and that it creates a variable called itemList. Here, I add a predicate that tests to see if the current DSO has already been added to the itemList, and only adds it if needed. The qty calculation just counts the length of the string when split by the delimiter, subtracting 2, as there is always going to be 2 more than expected, since the delimiter is the first and last in a list...even an empty list will have a delimiter here, so a split will give you a list of length 2, which correctly returns 0. So here I needed to add something to the predicate and the output exprs.

    In the second example, I don't use the underlying knowledge of the itemList existence, and just do a sort unique to throw all the dups away...you mentioned this can't work, but I am not sure why, so I left this in to show how it could work; I might be missing something in the use case. In this, I throw away randomly any duplicate records, and then use the standard behavior of reduce to list. I added a count() expression and emited that to give you the count of the unique length...you could also add a filter after this reduce to list node and use the logic I used above in example 1 to just split("*").len() - 2 to get Qty.

    In the third example, I highlight how doing a sort and then agg is a little better in de-duping, as you can control what gets dropped. You would want to add a sort criteria to the sort node, and then you will drop the last in the group on that agg node, and do the same as the reduce to list as the second example.

    I hope this helps.
    Cheers
    Rich
    Attachments:
    Example Reduce To List.brg


  • 3.  RE: reduce to list of distinct values from field "listed"

    Employee
    Posted 10-24-2012 04:03

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

    Originally posted by: Gloria

    Rich, you are priceless. The first example provided exactly what I needed, without having to change the multiple nodes already in the graph I'm working on.

    Thanks loads.
    Gloria


  • 4.  RE: reduce to list of distinct values from field "listed"

    Employee
    Posted 10-24-2012 06:37

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

    Originally posted by: rboccuzzi

    Thanks Gloria! Glad to help