First time it appears on a DataTable

Hi,

I’m really struggling to solve that.

I have a data table that has values that can repeat, I need to get row data only on the first time it appears.

Example:

NAME / Country
John Doe / USA
Maria / Brazil
John Doe /USA

I just need to get row items(Name and Country) the first time John Doe appears.

Thanks for the help!

Hi,

Can you try the following expression? It removes duplicated rows.

dtNew = dt.DefaultView.ToTable("dtNew",true)

Regards,

1 Like

@Yoichi

I don’t know because it can have just a column equal, like only the name. Actually I have to filter it by just one column. If it works for columns it will do! Thanks for the help.

Regards

Hi,

Actually I have to filter it by just one column.

How about the following?

dtNew = dt.AsEnumerable.Where(function(r) dt.Rows.IndexOf(r)=dt.AsEnumerable.Select(function(x) x("NAME").ToString ).ToList().IndexOf(r("NAME").ToString)).CopyToDataTable()

Regards,

1 Like

I solved it, didn’t say your last reply till now, I’ll try this way too. Thanks…

Hi, I’m trying it to delete duplicated values from my Data Table but I think I’m not using it correctly because it is not removing the duplicate. I read an Excel range “D11:D15” (there are five cells, two of them with the value “1021” and three empty cells) and I assign the read range output as “BUsTable”, after this, I use an “Assign” activity to set the value of BUsTable2 = BUsTable.DefaultView.ToTable(“BUsTable2”,true)

image

image

Finally I’ve solved it using a “Remove duplicate rows” activity, it works perfectly with it: