cancel
Showing results for 
Search instead for 
Did you mean: 

Collection - Remove Duplicated Values in Specific column

MateuszWojcik
Level 5
Hello,

I have action which remove duplicated rows in whole collection. 
Collection_Out = Collection_In.DefaultView.ToTable(True)

I want to write new action which remove duplicates value only in specific column.

Does anyone have solution for this?

Thank you in advance

------------------------------
Mateusz Wojcik
RPA Programist
Rockwell Automation
Europe/Warsaw
------------------------------
12 REPLIES 12

i have try your code but i got error, can you help me

------------------------------
IAN NUGI
------------------------------

Hi IAN NUGI,

I send word document where you can find whole page from object.
Please paste it in your object Utility - Collection manipulation.

Please let me know if it works


Kind regards

------------------------------
Mateusz Wojcik
RPA Programist
Rockwell Automation
Europe/Warsaw
------------------------------

Hi,
I can share my code regarding removing duplicates:
Create a code stage.
input:
<type collection> Input name: CollectionIn
output:
<type collection> output name: CollectionOut
<type text> ErrorMessage 

ErrorMessage = "";
CollectionOut = new DataTable();
DataTable dt1 = new DataTable();
try
            {


                dt1 = CollectionIn;

                DataTable dtMerged = dt1.AsEnumerable()
				.GroupBy(r => new {d= r.Field<string>("put here column name from your collection") })
				.Select(g => g.First()).CopyToDataTable();
                CollectionOut = dtMerged;
            }
				catch (Exception ex)
            {
                ErrorMessage = ex.Message.ToString();
                
            }

Namespace Imports:
System.Linq
System.Reflection
System.Collections.Generic

External References:
System.Linq.dll
System.Data.Common.dll
System.Core.dll
System.Data.DataSetExtensions.dll

Hope this will help:)



------------------------------
MIROSLAW GADEK
CI & QUALITY MANAGER DACH
Schneider Electric Operations Consulting GmbH
Europe/Berlin
------------------------------