Filtering a Repeating Group by Unique Element

Hi!

I have a Repeating Group displaying Publications (via Do a search for). Those Publications have Creators. Creator’s number of Publications range between 1-30, and I have 50 Creators.

I want to Randomly display those Publications in the Repeating Group, but I want to filter it in such a way that it doesn’t show more than 1 Publication by the same Creator .

For example: If the Repeating Group displays 9 random Publications, it can’t show more than 1 Publications by Creator Peter. It either shows 1 or it doesn’t show none at all (since there are plenty of Publications and Creator, and Publications are shown randomly each time the page load).

1 Like

Thinking simplistically here (w/out going custom, which is beyond me)… How is your data structured? If your Creator datatype has a list of Publications (so each Creator entry has a field which lists all the Publications that Creator wrote), could you…

  • Do a RG of Creators, random sorting, and set :items until to whatever count of Publications you want.
  • In the RG cell, put in a text element and have it populate as Current cell’s Creator’s Publications: random item’s Name

That should therefore create a random set of Creators, and for each Creator, pick one random publication, resulting in a random list of publications, with no more than 1 per Creator. Downside is that this equally weights the Creators in terms of how articles are selected.

Otherwise to have the random selection weighted more by Publications, there would have to be a way to do a list of Publications up until a specific number, randomly sorted, and having the Creator be a unique element so that a Publication isn’t added into the list if another Publication with that Creator is already in the list. Maybe filters or advanced filters could handle, don’t know. Or experiment with a workflow and a custom state to add an article to a custom state list only if the article’s owner isn’t already in the custom state.

2 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.