Sorting a list by a reference field / average value of reference field

Hey everyone!

I’m having trouble figuring out how to sort lists by reference fields.

Two scenarios where I’m having trouble:

Picture something similar to AllTrails, we have Activities (like a hike for example). The activities are linked to different collections:

  • Reviews: one activity to many reviews
  • Difficulty: many activities to one difficulty
  1. I want to be able to sort the list by difficulty. I assigned numbers to the difficulties (to be able to create an ascending/descending order from Easy, Regular, Hard) but I am not able to sort by the reference field.

  2. I want to be able to sort from best review to worst. This requires calculating the average review score from multiple user reviews (created using the star review component). Again, can’t sort via the reference field with the added dimension that this would need to be an average of all the reviews that reference this specific activity.

Is this even possible? // Has anyone found a workaround for a similar build?

Thanks in advance for any tips!

Hi @JohnKrueger,

Not possible at the moment, unfortunately. But this would be great! In the meantime you can create a number property on the Activities collection and update that when creating a new activity and sort the list with that property!

Not possible too and needed a number property on the Activities collection and update that every-time when creating reviews with current activity > reviews > rating > average and sort the list with that property!

Made a quick app that you can check! : Activities Sorting

Hope this helps!

Thank you

1 Like

Hey Dilon,

Dang, that’s too bad for both items. I guess we will just have to make due with the manual workaround for now.


Does anyone have an idea if this, or something in this direction is in the works? Being able to type a function to automatically generate a value in a collection would be awesome! (like in airtable)

Hi @JohnKrueger ,

To have a sorting field, it needs to be inside the collection, you can have additional calculated fields to do that, you can perform synchronized updates every time the relational collections is updated or just before needing to show the list.

About function, it may not like the one in spreadsheet but you can check custom formula and put them in input text field at initial and have couple of them put together or combine with logged in user> numbers field.

1 Like

Hmm ok, I see how that could work. I’ll give it a try. Thanks!

Does anyone know if this would be possible via the arbitrary javascript component from Pragma Flow?

By having both number parameters inside of the activity collection, you’re able to use them as sorting filters, just like @Yongki & @dilon_perera stated.

Here’s a more detailed explanation:

Add a number parameter to your activities and call it “Difficulty #”. Then you can use that as a sorting filter for the activity. 1 - easy, 2 - regular, 3 - hard. You can sort high to low for hard-to-easy or low-to-high for easy-to-hard. Also add the difficulty number to the difficulties collection. That way you can use a dropdown or option that says where current activity difficulty # is equal to Difficulties collection number.

Add another number parameter to your activities and call it “Average Rating”. Whenever a user leaves a review for an activity, add another action to update the activity and set the value to “current activity > reviews > rating > average”

I have added that on my post with a clonable app too! So you need to two number properties on the Activities collection.

Oh like that Formula column in Airtable? There’s no column for that and needed to perform a action to update that row. Is it possible to give an example?

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.