SORTING... by a calculated value not in the table or data variable


I have a table called X with say: ID MEMBER-ID
in the table MEMBER, I have MEMBER-ID and MEMBER-NAME

when I display records in table X, how do I display them sorting by MEMBER-NAME


You could use SORT_BY_KEY Formula to do that. So when you set your variable or directly in the Repeat with field, use the Formula to sort your records.

So are you suggesting a wrap a SORT around the following which is the first field in the row of fields that I display…

LOOKUP(FIND_BY_KEY(data.Messages,“id”,current.MessageID ), “Message”)

I have a table of messages, and a table of messagesForMember. I want to display the messages for the Member so that table gives me the messages I need to display… so the above works and shows me the messages I need BUT not sorted by the date field in the messages table.

Using SQL this is dead easy. Hear I just have problems figuring out the best place to do it. So…

Not sure how SORT_BY_KEY would work…

I am displaying fields form messagesForMember:

id memberID messageID message(using lookup) to get the message text. To sort on date in messages table, I would have to … don’t know.

I am repeating by messagesForMember, but the date field is in messages, which I have on the page in the controls…

above… first field is.
LOOKUP(FIND_BY_KEY(data.Messages,“id”,current.MessageID ), “Message”)
second is the date field i want to sort on… LOOKUP(FIND_BY_KEY(data.Messages,“id”,current.MessageID ), “Date”)

neither are in the repeating group…

THANKS again.

I don’t quite understand the situation based on this information.

Where do you set values to Messages and messagesForMember? And those have their own tables backend?

And what do you repeat? It seems that you repeat those Paragraphs individually which feels odd and I’d suggest you to repeat a Container that has the two Paragraphs inside it. And you have current.message above those also.

Yes messages and messagesForMembers are their own tables and are already populated. Here I display the messagesForMembers records for a member. But to sort, I need the date in the message field.

Each message has a messageForMember record for every member (which is another separate table).

I see, what you are suggesting is 2 repeating groups in one container in effect I think making this like an SQL JOIN?

Okay, so as you basically want to repeat just messages in your table (though just the ones that are related to that specific member), you could use SELECT(). It would choose only the related messages to be shown and SORT() around that would do its part.

I think it would look something like this:

SORT_BY_KEY(SELECT(data.Messages, IS_IN_ARRAY_BY_KEY(data.MessagesForMember, "messageID",, "date")

Then just bind the repeated components to current.message and

beautiful, again thank you for your support.