Need to remove one row or more row based on condition

Note first image input and second image output
New Microsoft Excel Worksheet (2).xlsx (11.9 KB)

so for example for this string Not Found in Master Regular in the material column comes then (171-0084576-84627333)
from ref ord no column, if it repeats, means then it has to remove Not Found in Master Regular single row and then keep the two rows for this number 171-0084576-8462733 likewise it has to do it for others and the second condition is if Not Found in Master Regular in material column comes one time means then no repeating of 408-7695769-4842759 this in ref ord no means then it should not remove that row and third condition some times in material column only not found in master also can come for that it should not remove so any please share linq query or how to do this


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() (11.5 KB)


1 Like

Thank you so much Yoichi it is working and from the bottom of my heart I’m saying this I’m really happy to see a great person like you in my life…

1 Like

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