Is there a way to add a ranking column to a html table of numbers?

Is there a way to add a ranking column to a html table of numbers?

Jeff AJeff A Posts: 50Questions: 8Answers: 0

Hi, Is there a way to add a ranking column to a html table of numbers? I'm trying to replicate a table that was created in Excel using Excel's Rank() function. Anyone know if this can be done using DataTables? I already have the numbers in html page. See two attachments.

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    What does Excel's Rank() do?
    Also, what is your data source - are you somehow importing from Excel, or using a database, or what? I ask because a database is likely to have a corresponding method of its own.

  • Jeff AJeff A Posts: 50Questions: 8Answers: 0

    RANK: Returns the rank of a number in a list of numbers. The rank of a number is its size relative to other values in a list. (If you were to sort the list, the rank of the number would be its position.)

  • Jeff AJeff A Posts: 50Questions: 8Answers: 0

    our software where we build reports doesn't have such a function.

  • Jeff AJeff A Posts: 50Questions: 8Answers: 0

    Anyone have any suggestions?

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,953

    Took up the challenge. Used the code in the 2nd post here to calculate the ranking. Did not validate the accuracy of that code. Will leave that to you :)

    Used drawCallback to calculate the ranking. Basically the function gets an array of column 3 (extn) values then ranks them into another array. Then it loops through each row and saves the ranked array into column 4.

    Here is the code:
    http://live.datatables.net/bexupefa/1/edit

  • Jeff AJeff A Posts: 50Questions: 8Answers: 0

    thanks so much!!!. I will try this out..

  • moikmoik Posts: 2Questions: 0Answers: 0

    Hi! I've been looking for the code for years now. Thank you so much.

    Is there a way to get the reverse ranking of the "extn" column? The lowest number is the rank #1 ?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    @moik See the other thread you commented on

This discussion has been closed.