I have Ranking as a Data Type where I keep the points earned for each member. Ranking has Name, Points and Rank as the data fields. For example, if I have the follow data in Ranking with Name and Points.
You can just use the :sorted command in the repeating group and then choose the database field that you wish to sort by (rank) and choose descending is “yes”
So if I get you correctly, essentially your Users have points. If you sort a list of Users by points (descending) and secondarily by some other factor (User’s name? Last time they played? I dunno… pick anything), there’s your “Rank” amongst those Users.
Rank is a derived value based on points. It may not really make sense to write Rank as part of a Ranking as a User’s Rank is actually regularly changing.
The style of ranking you’re doing here is sometimes called “dense” ranking. It’s almost like simply using the index of the RG you’d display a sorted list by points in, but adjusted for how many duplicated ranks (“ties”) there are in the list.
There must be a fairly simple algorithmic way to display this as you did in your mockup above:
The Rank # is the current cell's index minus (the difference between the number of rows above [which is current cell's index -1] and the number of unique scores in the rows above [which is the RG's list of things's Points:unique items:items up to current cell's index:count])
It just needs a bit of playing around with but the above should put you on the right track…?
Row 1 is the leader (1st place): Index 1 should always be ranked as 1 of course.
Row 2 is tied for leader (1st place): Index 2 - (2 - 1 unique score to this point) = 1
Row 3 is 2nd place: Index 3 - (3 - 2 unique scores to this point) = 2
Row 4 is 3rd place: Index 4 - (4 - 3 unique scores to this point) = 3
Row 5 is tied for 3rd place: Index 5 - (5 - 3 unique scores to this point) = 3
Row 6 is 4th place: Index 6 - (6 - 4 unique scores to this point) = 4
Etc…
So the text box in your RG under rank should print out:
Current Cell’s Index - RG’s List of Things’s:Items until Current Cell’s Index:unique items:count *-1 + Current Cell’s index… (if I’m not mistaken… the wonky way of writing this expression is due to Bubble’s left to right order of evaluation…
Oh… HA HA HA! There’s clearly some algebraic simplification I didn’t do there.
But I’m SO GLAD you followed along with me and figured out how to do this! This is the type of thought process I go through all of the time to create new features in Bubble.
Now that you know how to do these crazy compound type computations, you’ll find yourself using them all over. It’s just a different sort of math than we are used to.
(Thinking list-wise [as opposed to thinking “loop-wise” – iterating over an array of things multiple times “in your head”] is a form of parallel computing. It’s very powerful, but a little tweaky sometimes as we sort of default to thinking about things in the loop-wise way. Visualizations – like your very smart writing out of “here is how I want it to look” – are key in figuring this kind of stuff out.)