Can you try the following?
Code:
(From row In dtInput.AsEnumerable()
Group row By Brand = row.Field(Of String)("Brand") Into Group
Let sortedGroup = Group.OrderBy(Function(x) x.Field(Of Double)("Value"))
From item In sortedGroup.Select(Function(x, index) New With {
.Brand = x.Field(Of String)("Brand"),
.Value = Convert.ToInt32(x.Field(Of Double)("Value")), ' Convert to Int32
.Priority = If(index = 0, "HIGH", "LOW")
})
Select dtOutput.Rows.Add(item.Brand, item.Value, item.Priority)).CopyToDataTable()
Input:
Output:
Sequence9.xaml (10.4 KB)
Cheers!!