cancel
Showing results for 
Search instead for 
Did you mean: 

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

Sri_Krishna_Cha
Level 5
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 ?
7 REPLIES 7

BastiaanBezemer
Level 5
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:  

BastiaanBezemer
Level 5
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

GaneshChokkaiya
Level 2
Hi Bastiaan, The code is working as expected. Thanks for your help !!

VeraPeute
Level 2
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  

John__Carter
Staff
Staff
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("",""))]]>

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.
Thanks!

------------------------------
Harshali Rane
------------------------------

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:)
Thanks,

------------------------------
Harshali Rane
------------------------------