0

HELP ME RANK PLEASE

I have a table in Ninox, lets call this table, Table A. This table consists of the column Name of cars, and Scores. Please see the screenshot in the attachment. Which scripting code can I use rank these cars?

So logically, I need to sort the score of the cars descendingly. The first score on the very top (highest score) should be ranked as 1, second highest should be ranked as 2, and so on.

Which coding should I use to achieve this? I am new to coding so I really need help on this! 

Thank you very much.

Best regards, 
Vinson Javiero

6 replies

null
    • Fred
    • 7 mths ago
    • Reported - view

    Are you asking for code that you can put in a button that will rank the records for you?

    • Vinson_Javiero
    • 7 mths ago
    • Reported - view

     Hi Fred, thanks for the reply. Yes I am asking for the code that I can put into the formula field to rank the records. Could you please help me with this please?

    Best regards, 
    Vinson Javiero

    • Fred
    • 7 mths ago
    • Reported - view

    You can put this in a button in any table:

    let myCount := 0;
    let getCars := (select TableA);
    for loop1 in getCars do
        let xScore := loop1.Score;
        let myCount := cnt(getCars[Score > xScore]);
        loop1.(Rank := myCount + 1)
    end
    

    This is assuming Rank is a number field.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 7 mths ago
      • Reported - view

      Fred Hi Fred👍

      When I have a two equal rank there is a problem, it gets complicated.

      • Fred
      • 7 mths ago
      • Reported - view

      If they are equal then they should be ranked the same, no?

      How else would you rank them?

      You would need a 2nd field to use as a tie breaker.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 7 mths ago
      • Reported - view

       You're right

Content aside

  • 7 mths agoLast active
  • 6Replies
  • 59Views
  • 3 Following