Need To Remove the Row on the basis of Duplicate value in Column

There is a scenario , in which column1 has duplicate value.
Need to remove the completed DataRow in against the duplicate value.
Refer the image->
image

1 Like

@Vaibhav_Rajpoot_17 , Try this

  1. Read the Excel file and store a variable as"ReadDataTable"
  2. Assign activity - NewDataTable=ReadDataTable.Defaultview.ToTable(True, “Column1”,“Column2”,“Column3”).
    Note: NewDataTable is
  3. Write range, check the header, Pass the NewDataTable as a input.

@Vaibhav_Rajpoot_17 , also can use Remove Duplicate Excel activity
image

Hi @Vaibhav_Rajpoot_17

How about this expression?

(From p in DT.Select() where( From q in DT.Select() where q("Column1").Equals(p("Column1")) Select q).ToArray.Count=1 Select p).ToArray.CopyToDataTable()

Regards
Gokul

Hey!

Try this

DtNew=Dt.DefaultView.ToTable(True)

The above expression will remove the duplicates in entire table

If we wants to remove the duplicate records in particular column we can try like this

DtNew=Dt.DefaultView.ToTable(True,"ColumnName1","ColumnName2")

Regards,
NaNi

Hi @Vaibhav_Rajpoot_17

Please try this approach

image

(
	From row In dt_Data.AsEnumerable()
	Group row By k=row("Column1")
	Into grp=Group
	Select grp(0)
).CopyToDataTable

Xaml for reference

RemoveRowsBasedOnDuplicateValueInColumn.xaml (7.6 KB)

1 Like

how about this lets try

dt.AsEnumerable().GroupBy(Function(x) x(“ColName”).ToString)[Select](Funtion(y) y.First()).CopyToDataTable()

dt = dt.AsEnumerable.GroupBy(Function(x) x(“Column1”)).Select(Function(g) g.First()).CopyToDataTable

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