# How to calculate Rank according to student percentage

i was trying to calculae rank according to the percentage of the students

for eg

90.66 = 2
97.80 = 1
88.90 = 3
88.66 =4
and so on

here is my
Marksheet Updation.zip (16.8 KB)

Checkout this Xaml ands output file

Main.xaml (52.1 KB)
Marksheet Data.xlsx (15.2 KB)

No Ranks will be provided for the students who have failed in any one subject too right so i have added “NA” for that

Regards
Sudharsan

thanks it is working but if there is a simple solution please let me know , becuse i didnt understand it what is going on here

Okay so nothing complicated here @sagar.raval

In this assign i’m sorting the Obtained Marks in descending order with this expression

``````dataoutput.AsEnumerable.OrderByDescending(Function(x)CDbl(x("Obtained marks").ToString)).CopyToDatatable
``````

Looping through each and every row of the datatable dataOutput

• Used look up datatable to get the rank count(With row index) and the FailedSubjectCount(With column value of AtKt column)
• If condition to check if FailedsubjectCout>0
• True-> CurrentRow(“Rank”)= “NA”
• False-> CurrentRow(“Rank”)= Rank(Rowindex of lookupdatatable)+1

How this will work is like

• Taking the first row ,in lookup datatable it will look for the total mark in the RankArray datatable(Which we have sorted as descending)

You know that row index will start from 0 so i have added rank +1 to get the correct rank

Regards
Sudharsan

1 Like

tysm for that detailed answer

1 Like

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