Keep unique of each Duplicate

I have a datatable with Multiple Columns. I want to check duplicate in Column B and keep unique out of each duplicate e.g below

Column A Column B
1 Orange
2 Orange
3 Grapes
4 Apple
5 Apple
6 Kiwi

Output should be below

Column A Column B
1 Orange
3 Grapes
4 Apple
6 Kiwi
1 Like

Hi @somesh.r.nagar

Try this linq query:

YourDataTableVariable = YourDataTableVariable.AsEnumerable().GroupBy(Function(row) row.Field(Of String)("Column B")).Select(Function(group) group.First()).CopyToDataTable()

Hope it helps!!

1 Like

hey @somesh.r.nagar
try this:
dtInput.AsEnumerable().GroupBy(Function(row) row("ColumnB").ToString()).Select(Function(g) g.First()).CopyToDataTable()

image

1 Like

Hi @somesh.r.nagar

You can simply use the Remove duplicates activity, it is the excel activity.

Check the below workflow for Excel activities,
→ Use the Excel Process scope activity and insert the Use excel file activity inside of it and pass the file path.
→ Inside Use excel file activity insert the Remove duplicates activity.
→ Specify the range in the range field, check the Compare individual column option and Click on add Column and give the column name with in the double quotes.

Check the below workflow for better understanding,

Input -
image

Output -
image

Hope it helps!!

1 Like

Hi,

Read the input data in datatable. Then use remove duplicate activity. This will solve your issue.

Thanks

1 Like