Delete repeated rows (delete the first row of the repeated data)

Hello everyone, I have the following data table, as you can see in Column1 I have data 81 repeated, I must delete the first row that has the data repeated, that is, I would have to delete row 5, how can I do it?
image

Hi @Juan_Esteban_Valencia,

Check this workflow

  1. get Clone datatable for dt_Output
  2. get distinct value for “Column1”
  3. select the CurrentRow value datatable and do Reverse the datatable then get rows 0

Input
image

Output
image

Workflow

For Each Row in Data Table
dt_Input.DefaultView.ToTable(True,"Col1")

Add Data Row
dt_Input.Select("Convert(Col1, System.String)='"+CurrentRow("Col1").ToString+"'").Reverse.CopyToDataTable.rows(0).itemarray

Xaml
Sequence.xaml (12.4 KB)

Thanks,

Hi @Juan_Esteban_Valencia,

one more method via LinQ

Workflow

Code

(From row In dt_Input.DefaultView.ToTable(True,"Col1").AsEnumerable
Let r = dt_Input.Select("Convert(Col1,System.String)='"+row("Col1").ToString+"'").Reverse.CopyToDataTable.rows(0)
Select dt_Output.Rows.Add(r.itemarray)).CopyToDataTable

Thanks,

Thank you very much, both ways worked for me

1 Like

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