How to calculate the Rank?

Hi All,

I hope everyone doing well.
I stuck in a scenario that I want to calculate the Rank of the students from the list of marks list which is in excel.
Like
Total_Marks | Rank
459 2
296
260
435
342
262
494 1
380
340
323

From above marks I need to calculate the rank of the each student.
Which student scored more marks he should assign with 1st rank,then 2nd rank and so on.

From above example the guy who scored 494 will need to assign 1st rank and for a guy who scored 459 should get the rank 2nd and so on the guy who scored least marks should get last rank…

Please somene help me to resolve the issue.

@Palaniyappan
@geetishree.rao
@NIVED_NAMBIAR
@Sudharsan_Ka
@kirankumar.mahanthi1
@ppr
@pravin_calvin
@lakshman
@Robinnavinraj_S

1 Like

dt = dt.Select("",Total_Marks desc").CopyToDataTable()

then update the Rank in increment mode.

Regards,
Arivu

1 Like

Hi @HeartCatcher

I think you can use Sort datatable.
Specify the column you want to sort in, and then use the descending sort. If there is no column to index, why don’t you add one?

1 Like

Can you please elaborate with the code??

lets assume you do have a Excel with2 cols : the filled TotalMarks, Rank
readin data with read range - dtData (2cols)

clone dtData for the report (Assign Activity)
dtReport | DataTable = dtData.Clone

Fillup dtReport (Assign Acitvity)
dtReport =

dtData.AsEnumerable.OrderByDescending(Function (x) Cint(x(0).toString)).Select(Function (x,i) dtReport.Rows.Add(new Object(){x(0),i})).CopyToDataTable

As Alternate we can also do it with essentials

  • sort the datatable
  • for each row
  • using for each row output index for the rank updating
1 Like

Hi @HeartCatcher
Sort Rank.zip (7.3 KB)
please find the sample code for the above query , i have done in a simple way (Non Linq)
just run the file and try to understand how it works ,attached input file too

Thanks

1 Like


PFA

let me know if it works or not

thanks

@HeartCatcher Just go to excel and check any spaces in column name
Test.xlsx (7.8 KB)
or just use this

or u can only create an excel with columnname “Marks” and “Rank”

and leave rank column empty

@HeartCatcher you can try with applying Excel formula in UIpath in assign activity…
in write cell you have to do this steps → Screenshot (12)

and in assign →
Screenshot (14)

Let me Know if it Works or not.

1 Like

@harshali.mangukiya,

What is K and L here??

1 Like

HI @HeartCatcher

Done some changes in @nikhil.girish flow

Can you please check on this

Sort Rank.zip (7.3 KB)

Regards
Sudharsan

Please provide the workflow.