Need to remove one row or more row based on condition

Hi,

How about the following?

dt.AsEnumerable.GroupBy(Function(r) r("ref ord no").ToString).SelectMany(Function(g) g.Select(Function(r) r).GroupBy(Function(r) r("material").ToString).SelectMany(Function(g2) if(g2.Key="Not Found in Master Regular" AndAlso g.Count>g2.Count,New DataRow() {},g2.Select(Function(r2) r2)))).CopyToDataTable()

Sample20230919-1L.zip (11.5 KB)

Regards,

1 Like