Sorting Linked Records in Views

I have a set of tables with a descending set of relations. Grandparent has children which have children etc.

I choose the linked records from a parent record and this stores my order since the ordering is dependent on the parent.

When I create a view from the lowest level I want to be able to group by the ancestors and then sort each group by the linked order. I only get options for alphabetical.

Is there some other way around this? Can I somehow get a calculation to expose the ordering of the array of linked records?

Hello @Greg_Jarmiolowski!

So from your base description it sounds like creating a field just for your grouping purposes would be helpful here. Linked Record’s orders are dynamic within the field, so you can’t sort by the order of the records listed organically but you can add some information to the linked record in order to use that information for sorting purposes.

For example say I have a table setup with links to parent records:
Demo+Base_+children+2021-05-19+at+8.35.34+AM

You can group by the parent field and sort by the field as well (which is what I suspect you are doing):

And then the records will appear in order by the parents fields value:
Demo+Base_+children+2021-05-19+at+8.37.07+AM

So if we add a number to each parent specifically to keep the order of that parent for all children records:

Now sorting by name will sort by the numbers included in those records:
Demo+Base_+children+2021-05-19+at+8.40.51+AM

This is just my initial idea on how to address this problem. In order to dive in a little deeper into your use case it would be helpful to know a little more about your table set up and what your parent records look like. Screenshots are always amazing (feel free to DM them to me if that would make you more comfortable).

Let me know if I can help provide any more information, and if this helped answer your question please mark it as the solution :white_check_mark:.

1 Like

Thank you for this. I need to try this in reverse though because my links are pointing at children and I want children in order under their grouped parent (within a group by in a view)

In most databases we think about the child having one parent. But I have 4 levels here all following this pattern where the child records can have multiple parents.

The order of the children is determined by the links in the parent. I don’t choose the parent of a child record, I choose the children and order them within the linked record selector form. I cannot just add a column for order because the order isn’t a singular thing. On parent I could have something like “Order of Children” but even if I managed to figure out this data it is on the wrong level for sorting in a group by view. So I could pull this parent column into the child table. Maybe it looks like “Apple, Cat, Bear” where these are the IDs of the children. Now I could create a formula that looks at the current record ID and finds which position it matches in the “Apple, Cat, Bear” sequence…but I cannot because there aren’t really any array lookup functions. Oh wait this wouldn’t work because I also have multiple parents so I would end up with an array of arrays to sort through and no way to determine which parent I am being grouped under in this pass through the view’s internal iterator.

In code this is trivial. I get the array of links and loop, then the next array of links and so on. I can nested loop my way through it all. But this isn’t possible in a view because the order of the linked records is not exposed.

In SQL DB I would use cross reference tables. Maybe I need to do that here too. I just thought that the array of linked records concept Airtable uses would save me some effort. Maybe now I see why SQL doesn’t support arrays of keys.

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