Topic Thread

Expand all | Collapse all

Do we have any Collection action that can remove the duplicate values of a specific field and give me only the unique values?

  • 1.  Do we have any Collection action that can remove the duplicate values of a specific field and give me only the unique values?

    Posted 03-18-2018 17:10
    I am reading values from the excel now I would like to eliminate the duplicate entries of specific field and then give me only the unique values? Is there any Action that can do this work for me ?

  • 2.  Hi Chaitanya,…

    Posted 03-19-2018 13:04
    Hi Chaitanya, You'll need to write your own code stage for this in an object: 'IN: Collection_In (as Collection)'OUT: Collection_Out (as Collection) Collection_Out = Collection_In.DefaultView.ToTable(Only_unique_values_of_columns) Many more interesting things can be done, e.g. only output certain columns. But i trust that above line of code will already meet your need. For more documentation, feel free to refer to the official documentation:  

  • 3.  RE: Hi Chaitanya,…

    Posted 06-18-2020 05:36
    Hi Bastiaan,

    Is there anyway to remove duplicate rows from collection using .net code stage. Suppose I've one collection with 3 columns and if some rows have same data in all of these 3 columns I need to keep only single row(get unique row) and remove others. I've tried the code you shared here. But it is only working if I have a single column collection. Could you please provide your thoughts on this.

    Harshali Rane

  • 4.  RE: Hi Chaitanya,…

    Posted 06-18-2020 06:06
    Edited by Harshali Rane 8 days ago
    Hi Bastiaan
    No need to reply. In this case, we need to just pass the column names (comma separated strings as arguments)in the function basis which we need to remove duplicates. It is tested and verified. Thank you for your initial post. It helped me achieve what I wanted in my current project:)

    Harshali Rane

  • 5.  P.s. forgot to mention one…

    Posted 03-19-2018 13:43
    P.s. forgot to mention one input value: 'IN: Collection_In (as Collection) 'IN: Only_unique_values_of_columns (as Flag)'OUT: Collection_Out (as Collection) Collection_Out = Collection_In.DefaultView.ToTable(Only_unique_values_of_columns) Good luck

  • 6.  Hi Bastiaan,…

    Posted 04-18-2018 17:58
    Hi Bastiaan, The code is working as expected. Thanks for your help !!

  • 7.  Hi, I used above mentioned…

    Posted 04-10-2019 21:45
    Hi, I used above mentioned code stage. However I would like to get an output collection in which not only the column with unique values is present. but also all the other columns from input collection. This because my input collection contains data I need to put in another file. However, I only need to put the values there that are unique regarding one column. For example: A     1       R       5 B     1       B       6 B      2      B       6 C      4      R       5 C      3      B       6   If you look at this, I would like to get the unique values from the first column, so only A B and C. But together with the data behind it (concerning the first row value is mentioned), more like removing duplicates in an Excel file. However, with above mentioned code stage I would get a collection out with only A B C in it. Is there an option to get this done? Except using a loop to get the value and see if this value is already in the ""Unique Value - collection"", and than either adding it to this collection or skipping when value is already present. Thanks in advance! Vera  

  • 8.  Paste this into an object,…

    Posted 04-11-2019 18:10
    Paste this into an object, it might be what you're after. You supply the collection and a CSV text of the column names where you want a unique combination of values. 6217b5e5-308c-4c75-b555-28f29403f8e615-306030 Collection_Out = v.ToTable(true, Column_Names.Split("",""))]]>