Delete Dup by condition?

I want to check dup by row condition as below.

  1. CusName and PlanCode as same → check value in column FPP —> keep row that FPP
    most value
  2. CusName and PlanCode as same → value in column FPP same value ----> keep 1 row

Please guide me about it.
remark : Real Data have 1K rows
input2.xlsx (9.7 KB)

@Ramya_K You can guide me this case?

(From d in Input DT. As Enumerable()
Group d By K1= d(“Cust Name”). Tosting, K2= Tostring() d(“PlanCode”). Tostring() Into grp=Group Lett rw = grp.Asenumerable ().Orderby(Function (x) Cint(x (“FPP”))). First() Select ResDT. Rows. Add (rw)). Copy To DataTable()

Main.xaml (6.7 KB)
input2.xlsx (9.7 KB)

Now I use code as below.

(From d in Input DT. As Enumerable()
Group d By K1= d(“Cust Name”).Tosting,K2=d(“PlanCode”).Tostring() Into grp=Group Let rw =grp.Asenumerable ().Orderby(Function (x) Cint(x (“FPP”))).First() Select ResDT. Rows. Add (rw)).CopyToDataTable()

But show error.

Please guide me for solve it.

Everyone help for this case please ?


Hope the following helps you.

dtResult=dt.AsEnumerable.GroupBy(Function(r) Tuple.Create(r("CusName").ToString,r("PlanCode").ToString)).Select(Function(g) dtResult.LoadDataRow({g.Key.Item1,g.Key.Item2,g.Max(Function(r) Double.Parse(r("FPP").ToString)).ToString},False)).Distinct(DataRowComparer.Default).CopyToDataTable (10.1 KB)


@Yoichi If I can’t fix dataTable for Build Data Table because It more column.

I want output all column from input.


How about the following?


dt = dt.AsEnumerable.GroupBy(Function(r) Tuple.Create(r("CusName").ToString,r("PlanCode").ToString)).Select(Function(g) g.OrderByDescending(Function(r)  Double.Parse(r("FPP").ToString)).First()).CopyToDataTable (14.9 KB)


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