I have datatable as excel file and attached picture.
I want to check and remove duplicate row at col “item” and keep row if it has negative smallest value at col “quantity”
As my datatable, i want to remove the row highlighted yellow.
How to do to add condition into the my Lin.Q code below
(From row In table.AsEnumerable()
Group row By k1= row(“item”).toString.Trim
Into grp=Group
Let r = grp.Last
Order By Array.IndexOf(table.AsEnumerable.toArray,r)
Select r).CopyToDatatable()
(From d In dtData.AsEnumerable()
Group d By k1= d("item").toString.Trim Into grp=Group
Let mx = grp.Select(Function ( r ) Convert.ToInt32(r("quantity").toString.Trim)).Where(Function (w) w >=0).DefaultIfEmpty(0).Max()
From g In grp
Where Convert.ToInt32(g("quantity").toString.Trim) >= mx
Order By dtData.Rows.IndexOf(g)
Select g).CopyToDatatable()