Sort and filter on the Lookup field

Hello!
.
I’ve created a Lookup field on a Meeting entity I have (the lookup is from tasks related to the group responsible for that meeting) but the tasks appear sorted in a kinda confusing way. I can rearrange them manually, but I’d like to know if there’s a way to set up the sort, just like in the views. Also if there’s a way to filter, so I can see only the tasks that haven’t been done yet…

Thanks!

Sorting and filtering is available on relation views, but not on formulas/lookups.
If there is a single group linked to the meeting, and if a task belongs to only one group, then you could use an automatic relation rather than a lookup (matching on group) and then sorting/filtering becomes available.

1 Like

Oh! I’ve just discovered now the possibility of having more than one visualization on the relation inside the entity:

That solved my problem!
Thanks!

Is this going to be implemented for formulas?

I hope you do not mind the reopening of this topic, but I believe this is very closely related.

:white_check_mark: I love that the return type of a formula can be an entity type, which turns it into a filterable and sortable lookup by formula.

For example, on the Accounts table, to lookup its Operational Roles sorted ascendingly by the name of the Contact connected to the Role:

Roles.Filter(Lower([Role Type].Name) = "operations")
  .Sort(Contact.Name, true)

:cross_mark: The problem is that the sort is not respected in the field’s UI. But of course the formula itself does return it sorted, as we can confirm if we return the value as a joined text field by adding .Join(Contact.Name, ",").

Roles.Filter(Lower([Role Type].Name) = "operations")
  .Sort(Contact.Name, true)
  .Join(Contact.Name, ",")
1 Like

The Sort() function in formulas is not related to the sorting that is used when displaying collections.
It is typically used for when you want to extract the First() or Last(), or do something like Join() as you discovered.
But formulas utilise ‘backend’ functions, and they do not affect the ‘frontend’ display of the result.
Ultimately, the fix will come when it is possible to use the standard relation field component to display a collection of entities which are the result of a formula.
See here.
In that case, users will be able to set frontend filters and sorting on collections which are read-only.

Related: Unable to sort decending

Thanks for the clarification. I was thinking the Formulas with the Entity Return Type were used for exactly that, but in a read-only way.