Remove duplicates from two columns

Hi,

I have a data table DT1 with two columns

DT1 :

image

I need a solution which removes duplicates from both the columns.

Thanks in Advance.

Hi @Jnanesh_Ballal,

You can use remove duplicate rows activity.

Or

DataTable1 =DataTable1.DefaultView.ToTable(true,“country_1”,“country_2”)

Hi,

Can you share expected output?

Regards,

Expected output

image

@Jnanesh_Ballal

First first column dt.DefaultView.ToTable(True,"Country_1")

For second column dt.DefaultView.ToTable(True,"Country_2")

These are to be used in assign and you would get output with single column and unique values

Cheerd

1 Like

Thanks,@Harshith_Adyanthaya
I have used the
DataTable1 =DataTable1.DefaultView.ToTable(true,“country_1”,“country_2”)
but duplicates are not removed

Hi @Jnanesh_Ballal
dt.AsEnumerable.GroupBy(Function(r) Tuple.Create(r"Country_1").ToString,r(“Country_2”).ToString)).Select(Function(g) g.First).CopyToDataTable

Regards
Mohini

Thanks @Anil_G , tried this but only first column appears after removing duplicates.

Hi,

Another approach:

Can you try the following sample?

Sample20230410-5L.zip (8.2 KB)

Regards,

@Jnanesh_Ballal

Yes as you dont have a common duplicate…I have you two commands for each and then you can paste the data side by side in your excel using two write range activities

cheers

1 Like

Hi, @Jnanesh_Ballal

Try this one

DT1.AsEnumerable().groupby(Function(a) Tuple.create(a(“Country_1”).ToString.Trim,a(“Country_2”).ToString.Trim)).Select(Function(b) b.First).CopyToDataTable()

Regards,
Yajnesh

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.