Select to view content in your preferred language

Concatenate Unique values (only)

07-13-2023 06:12 PM
Status: Open
Labels (1)
New Contributor III

@KoryKramer @DrewFlater  The implementation of the concatenate option has been great, thank you, but what I see now is the need for a "concatenate UNIQUE" option.  See this tech support  example:

It lists the same value multiple times (i.e. 111).  I would like to see the option to only show unique values (111 would only show once).  My use of this today resulted in the same value populated numerous times making the field width in excess of 500 characters.  Would it be possible to add a checkbox option to only return unique values?

Previous idea:


1 Comment

You can run a field calculator on the concatenated field.



def sortValues(the_value, delimiter=','):
    """Sort a separated value into an order
    Useful to run on ArcGIS processes where there is no control on returned values.
    For example SpatialJoin, JOIN_ONE_TO_ONE, with FieldMapping Merge Rule = Join
    if the_value == None:
        return the_value

    # Create a Python list by splitting the string on the delimeter
    the_list = the_value.split(delimiter)
    # unique elements of the list using set()
    the_set = set(the_list)
    # turn the set back to a list
    the_list = list(the_set)
    # Sort the list

    # Reassemble the string from the sorted list
    rval = delimiter.join(the_list)
    return rval