# Create ranks based on collection ID's

**URL:** <https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608>\
**Category:** Ask for Help\
**Created:** [September 26, 2025, 12:41am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608 "2025-09-26T00:41:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 26, 2025, 12:41am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608/1 "2025-09-26T00:41:54Z")

</div>

Hey there,

I’m building a tool where users can submit speed runs for Lego builds.

I’ve got a Set table, a user table and a time table (for submitting times).

What I want to achieve is a ranked leaderboard for each Lego set. I followed a tutorial from @Robert_Petitto but it didn’t show how to create a rank exclusive for each collection row ID.

I’ve attached a screenshot to show where I’m currently up to. What I’m missing is the Rank/Position for the users. It’s currently showing Time taken, User name and date of submission.

Many thanks,

Mark

 ![Screenshot 2025-09-26 at 01.36.45](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/a/fa24f1364f0686af1a9740f5c099c6d4aabc8442.png)

---

<div class="post-metadata">

**Author:** ![Swift\_Struck\_24](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/swift_struck_24/32/91605_2.png) [@Swift\_Struck\_24](https://community.glideapps.com/u/Swift_Struck_24)\
**Post date:** [September 26, 2025, 6:01am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608/2 "2025-09-26T06:01:43Z")

</div>

Hi mark, a few questions:

1. are you using big tables or normal tables?
2. do you have the time taken value? is it in minutes or seconds?
3. If you do use a glide table, why not just sort your colleciton via the time taken (A-Z)? fastets comes first on the leaderboard this way

---

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 26, 2025, 9:49am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608/3 "2025-09-26T09:49:35Z")

</div>

Thanks for your reply.

it’s a standard Glide table.

I’m storing it as seconds at the moment.

it is currently ordered by time A-Z.

What I’m looking to achieve is showing a rank for the order. 1st, 2nd, 3rd etc.

The trouble I’m having at the moment is that I don’t know how to structure the database to provide ranks filtered by the set ID. If I build an array of ranks it does it across all set ID’s

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 26, 2025, 10:01am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608/4 "2025-09-26T10:01:32Z")

</div>

> [@Mark\_Bailey](#):
>
> What I’m looking to achieve is showing a rank for the order. 1st, 2nd, 3rd etc.
> 
> The trouble I’m having at the moment is that I don’t know how to structure the database to provide ranks filtered by the set ID. If I build an array of ranks it does it across all set ID’s

I can show you a way to do this. Can you show me a screen shot of your data table, so I can refer to that?  
Do you need to handle ties?

---

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 26, 2025, 10:13am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608/5 "2025-09-26T10:13:17Z")

</div>

Ah fantastic.

 ![Screenshot 2025-09-26 at 11.08.00](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/1/31d66c6973a3be28c86d7a3b03a9fe7489446aa8.jpeg)

Here’s the the table for the submitted times. I basically want to create a rank for each set ID based on ascending time. There will be multiple submissions per set by multiple people.

---

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 26, 2025, 10:31am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608/6 "2025-09-26T10:31:43Z")

</div>

Sorry I missed the question about ‘ties’. I’m not entirely sure what that means.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 26, 2025, 11:13am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608/7 "2025-09-26T11:13:32Z")

</div>

Another question: how do you want to present this in the Layout? Would have a single collection grouped by SetID, or would you have the user select a set and then present the rankings for that set?

Regarding Ties: lets say you have have 2 users equal 1st in one set. Would you want to indicate they are tied (eg. T1), or just show them both as number 1?

Also, I noticed that you mentioned 1st, 2nd, 3rd - is it important to include the suffixes, or would 1, 2, 3 be okay?

---

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 26, 2025, 11:18am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608/8 "2025-09-26T11:18:58Z")

</div>

In the UI I was hoping to display 1st, 2nd, 3rd for a collection grouped by set ID.

Ah ties! That would be a nice stretch goal yeah, I think once I’ve got the basic logic setup I’d like to include logic for ties.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 26, 2025, 11:56am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608/9 "2025-09-26T11:56:03Z")

</div>

Okay, you need 4 columns:

- Query column. Target the same table, filter by “Set ID is This row-\>Set ID”. Sort by Time ascending. Ensure multiple match is selected.
- Lookup column. Target the Query column and select Time. This will give you an array of Time values.
- Find Element Index column. “Values” should be the Lookup column, and “To find” will be the Time column.
- Javascript column: Pass the output of the previous column as `p1`, and use the following code:

```auto
let m = (p1+1) % 10;
let suffix = m === 1 ? "st" : m === 2 ? "nd" : m === 3 ? "rd" : "th";
return `${m}${suffix}`;

```

Those 4 columns should look something like the below:

 ![CleanShot 2025-09-26 at 19.55.13@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/0/20c5797a8a14f395aa74d85c6fb24cbbdf9a1b7e.png)

In the Layout, group your collection by Set, and Sort by Time.

---

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 26, 2025, 11:58am UTC](https://community.glideapps.com/t/create-ranks-based-on-collection-ids/84608/10 "2025-09-26T11:58:32Z")

</div>

Thanks! I’ll give that a bash and let you know how I get on!
