How to order repeating group that has related data

I have two tables, one called Table A and the other called Table B, in which the two are related. I set up a repeating group where the data source is Table A where it pulls the field and the value field from Table B. How do I order this repeating group by the value field?

1 Like

I think it should be done as follows:

  • Create a repeating group on your page and set its data source to “Table A.”
  • In your repeating group’s data source settings, you need to add a constraint that relates “Table A” to “Table B.” This constraint should ensure that you are pulling data from “Table A” where the related field matches the related field in “Table B.”
  • After adding the constraint, you can set up a sort for your repeating group. In the sorting options, select the field you want to sort by, which is the “Value Field” from “Table B.”
1 Like

As far as I know, there is no sorting option by either deeper field or another data type’s field. You can only sort by the fields of the data type itself (static or dynamically). Please someone correct me if I am mistaken.

But what you can do is a trick (probably costing more WUs) and can sort it by B’s value.

Here is my data structure. I have A’s and B’s. A has a B in it for the value, and B has the actual value.
image
image

Here are two repeating groups.

First one is just displaying A regularly, nothing fancy:
image

The second one is displaying A but sorted by B’s values.
image

And here is the trick. The second one’s data type is B and the source is a list of B’s from A’s (sorted by B’s values). See below.

And then, you will do a search for A’s and the constraint will be the current cell’s B.

You can see the whole example here:

1 Like

Here is the step-by-step process to order a repeating group that has related data: Blog article link