Delete duplicate row if one column contain certain special string

Hi Everyone One.

I have a datatable as excel file… I want to delete duplicate rows ( keep first row ) if match some conditions:

  1. The values at “Name” column are same
  2. The values at “Position” column = “Staff”

The output i want as below:
image

Thanks in advance!
Book1.xlsx (9.8 KB)

Hi @Mr.H
check this
Main.xaml (11.9 KB)

Regards,
Nived N

1 Like

Thanks you Bro.

But it not matched with my conditions.

  1. The values at “Name” column are same
  2. The values at “Position” column = “Staff”

The second condition is very important… it only check rows which have value at “Position” column = “Staff”… The value

I dont know how do this by Linq.

Thanks in advance!

Hi,

Hope the following helps you.

img20210820-2

dt = dt.AsEnumerable.GroupBy(Function(r) Tuple.Create(r("Name").ToString,r("Position").ToString)).SelectMany(Function(g) if(g.Key.Item2="Staff",{g.First()},g.Select(Function(r) r))).CopyToDataTable

Sample20210820-2.zip (9.5 KB)

Regards,

3 Likes

Thanks you very much!

1 Like

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