Forum Academy Marketplace Showcase Pricing Features

How do you rank user based on their overall scores and to two decimal places (eg 7.23)

Hello Bubblers, i need some help.

There is probable a simple way of displaying this information but i cant figure it out,

Basically I’m building a user ranking system based on their overall score, what i’m trying to achieve is a user ranking position (as a number with two decimals) based on their position relative to the highest users overall score and 0,

For example there are 100 users
User A has the highest score making his ranking position 10.00
User B is just above the middle making his ranking position relative to user A’s ranking position 5.25

The overall scores will continue to increase and the user with the highest ranking position will be the user with the highest overall score.

my thought process is to do a search for all users overall scores, take the highest and then give the current user a ranking position based on where they stand between the highest overall score and 0

I hope i have explained this correctly and in an understandable way.

thanks in advance


Thanks for your post! If you already have the scores saved in your database, and you want to display them in order of their scores to indicate a ranking, you might look into sorting the repeating group on that field. Check out our quick tip on this here. Let us know if that’s what you’re looking for or if you have any more questions.

Thank you for getting back to me! So I can sort users by there overall scores without an issue.

What I’m trying to achieve is to display there rank as a number (to two decimals like example above) on their profile which is based on their ranking position out of all user’s overall scores

I’ve done something similar in my app, but I’m not sure it’s the best way to do it…

I set the rank as a ‘Do a search for User’s (score > current user’s score):count’
(this is the number of people with score higher than your user)
Then, this is the rank number… people with the same score will have the same rank position.

But if you want to make a rank without same positions, with a second parameter, you can set as:
Do a search for Users (score >= Current user’s score; Second paramenter>Current users Second paramenter; etc):count

As by the “two decimals” I guess you can filter your search like
Advanced: Score:rounded to 2 >= Currented user score

(it would work better if you already register the score with 2 digits, if it’s not already, you can modify them)

1 Like

Gotcha, thanks for clarifying! Would something like the above post with the search for users whose score is above the current user’s score work for this part of your setup then? That could be one option for keeping the rankings relative to the other users at any given time, and similar to what I’d suggest, but let us know if we’re still missing any details of what you’re trying to build.

Thank you so much for your input, that would definitely work to show a users rank out of all users but it wouldn’t constrain the results in a scale of 0.00 to 10.00 i might not have explained it properly the first time and im sorry if thats the case! but ill see if i can re phrase the example, So users have a total score made up of a number of factors (this iv got working fine) what im trying to do is display a score/rank on their profile base on their overall score against all other users where 10.00 is the highest and 0.00 is the lowest, meaning the user with the highest score has a rank/score of 10.00 and the user with the lowest score has a rank/score of 0.00 for example…

if there are three users their rank/scores would be
UserA - 10.00 (highest overall score)
UserB - 5.00
UserC - 0.00 lowest score

if the are eleven users:
UserA 10.00
UserB 9.00
UserC 8.00
UserD 7.00
UserE 6.00
UserF 5.00
UserG 4.00
UserH 3.00
UserX 2.00
UserY 1.00
UserZ 0.00

If there are 21 users

UserA 10.00
UserB 9.50
UserC 9.00
UserD 8.50
UserE 8.00
UserF 7.50
UserG 7.00
UserH 6.50
UserI 6.00
UserJ 5.50
UserK 5.00
UserL 4.50
UserM 4.00
UserN 3.50
UserO 3.00
UserP 2.50
UserQ 2.00
User R 1.50
UserS 1.00
UserY 0.50
UserZ 0.00

examples with overall scores
UserA overall score of 5 - rank 10.00
UserB overall score of 3 - rank 5.00
UserC overall score of 1 - rank 0.00

second example with all over scores
UserA overall score of 98 - rank 10.00
UserB overall score of 67- rank 5.00
UserC overall score of 49 - rank 0.00

Sorry if thats abit OTT but i hope you get the gist, so it doesnt matter which user currently holds the top and bottom spot, is just matters what the top and bottom overall scores are and where the current users sits between those two points.

so i guess it needs to take into account the total number of users, the highest overall score the lowest overall score and where the current users overall score sits between those two points relative to all other users overall scores?

i hope thats a better explanation?

Please see above i dont know if it notifies you if i dont reply directly to your message?

You can make the position with a math expression based on the Rank position and the Number of Users…

The expression will be → Rate = 10*(Rank - nUsers)/(1 - nUsers);
and then round to 2 when you show it…
in the Expression element you will put:
10*(Do a search for Users (score>Current User’s score) - Do a search for Users)/(1-Do a search for Users)

Then you get this number by Expression A’s value:rounded to 2

If the rank is 1, the Expression will be 10
If the rank is last, the Expression will be 0
The rest will be a linearly progressive

1 Like

You absolute hero! I can’t say math is my strongest subject but that looks solid, would you be able to explain how I actually enter it?

I’m using a text element to display the rank as rank is not saved In the database as it’s dynamic…

So in the text element I click insert dynamic data…. and then… :joy:

Thank you so much for your help!

1 Like

Glad we’re getting closer to what you’re looking to build and that @ri_scc_94 has been able to help you out! When you go to enter this dynamic expression in the expression composer, one thing to note is that Bubble does not have built-in support for order of operations just yet. You might check out our tutorial on custom states for an example of how you can enter math operations so that they’ll evaluate the way you expect.

Oh yeah, I forgot… You need to install a plugin in your app, it’s called toolbox, then you will have the “Expression” element.

Then you add an Expression element to your page and types the equation there (it needs to be visible, but it won’t appear in your app)

Sorry for the delay in getting back to you, had a busy weekend! i have installed the plugin and have make the expression element on the page, but im having trouble inputting the expression.

im entering 10*(Do a search for users “in the constraint” total score>current user’s total score

But it leaves the red (more) input after i close constraint.

Would you mind helping me out on how exactly i input the expression?
Thank you

Have you set the Expression result as a ‘number’?

ps: you wrote the entire expression, right?

So Iv entered in the expression and set the result type as number, does it need to be do a search for users count?

When I put count the person with the highest overall score comes out as 11.11

oh yeah, you should put :count… as it is the number of the users