Hi can someone help me with the calculation.Here I am having a marks sheet so I need to calculate the number of subjects the student failed .Below is the image reference.
Try the below
Code:
' Sort the DataTable by Total marks in descending order
Dim sortedRows = dt.AsEnumerable().OrderByDescending(Function(row) Convert.ToDouble(row("Total"))).ToList()
' Assign ranks based on the sorted order
For rank As Integer = 1 To sortedRows.Count
sortedRows(rank - 1)("Rank") = rank
Next
' Accept changes to update the DataTable
dt.AcceptChanges()
Input:
Output:
Regards,
1 Like
Is there any other way to build the logic for this like using any kind of sorting activies.




