Forum Academy Marketplace Showcase Pricing Features

[Solved] Avoiding repetition of different things with same field value

How can I group, or at least avoid showing, in a Repeating Group the ‘things’ that have the same value in a specific field?

In other words, I want the current cell of the rep. group to show just one of all the ‘things’ with that value.

I have been facing that dilemma as well. You could create another field that distinguishes the “record number” field, the data in that field depends on the situation and it could automatically be inputted by you in the workflow or the user could input the data.

I’ve only figured out a way that ‘works’ when the repeating group type is ‘text’, and then there is a group within that cell who’s type is ‘Product’. I’m not sure if this is the right way to do it, but just incase it may help-- here it is in the forum app (link at bottom). :slight_smile: In this example, I wanted the repeating group to show only one thing with the Category value, and the single Product displayed by the repeating group is sorted/decided on by Price (In this example, if two Products have the same value for ‘Category’, the selected Product displayed in the repeating group will be the Product with the higher price out of the two. This is because the sort option is by Price, descending = yes).

App Data:

Here’s the result in the repeating group under the default setting ‘highest price’:

And here’s how it changes when ‘lowest price’ is selected from the dropdown:

Preview:

Editor:

1 Like

So an alternative is to have your category as thing, rather than text.

Instead of listing out Products, and then trying to make them unique … if you think about what question you are trying to ask … it is about Category and what products are the cheapest (or most expensive).

So your Repeating Group is Category, and then you go an search for a single matching product. I believe in the long run, as your app gets more complex (not that the above solution isn’t very clever :slight_smile: ) it will make your life easier to structure your data this way. But that does depend on what you are trying to do.

p.s. sorry for messing up the page, but I though it would be interesting to show both solutions together,

4 Likes

@NigelG, you are a lifesaver! :raised_hands: Thank you so much! I really appreciate you taking the time to explain that and show the correct solution. Now that I’m looking at your solution, I see that yours makes SO much more sense to search for Category instead of Text. I definitely need to get more practice with thinking about things in this way. Please know that you have total free rein anytime to edit any of my solutions in the forum app (not that you have to of course!) :smiley: ; it really does help me a ton to see the way you would structure things like this!

2 Likes

@fayewatson I saw you wrote a “Don’t do this” sign next to the repeating group. Which is the correct now then? :slight_smile:

@CapiBalid I just deleted my repeating group solution, and now only Nigel’s solution is visible on that page – his way is the way to do it :slight_smile:

Okay, so in order to achieve this -from what can I see from @NigelG - it is necessary to have one field depending on the other. Just as @muradamod explained above, right? For example: @fayewatson’s Product field depending on the Category one.

In my case, there wasn’t such a field, so I created another field yes/no type. Only one of all the Things with the same ‘Record Number’ value will be filled with a “Yes” value. Then, in the Do a search expression, I just set a constraint making Record Number = Yes.

Does anyone see a problem with this solution, or you think is fine?

From my understanding, right now you have ‘Record Number’ as a field, type: number, within a Data Type (similar to the forum example’s Data Type: ‘Product’). I’m not sure of the name of the Data Type in your application, here:

So I’ll refer to the above App Data’s Data Type as ‘Product’. Nigel’s solution explains that when your application gets very complex, your life will become much easier to make Record Number a Data Type, and then make ‘RecordNumberParent’ a field, type: Record Number within Product, instead of just having Record Number a field, type: number within Product.

My solution originally only had ‘Category’ as a field within Product, type: text – shown below:

We’re moving away from that, to the screenshot below where we structure our data so that it has a ‘CategoryParent’ field. The ‘CategoryParent’ field is the result of making ‘Category’ a Data Type first, then making ‘CategoryParent’ a field within Product, type: Category).

So, in summary:

  1. Nigel first created a new Data Type called ‘Category’. He created a field within Category and called it ‘description’, type: text)

    And here’s what it looks like in App Data:

2: Nigel then made a new field within Product called ‘CategoryParent’, type: Category. The ‘CategoryParent’ field’s type is Category, whereas before we had Category as a field, type: text. The difference between the two is shown below:

To follow similar steps in your application, I believe you would first create a new Data Type called ‘Record Number’:

And then you would create a field within ‘Product’ (called ‘RecordNumberParent’ for example, type: Record Number):

Once that’s set up, your Repeating Group Type of Content should be Record Number. Within each cell of that Repeating Group, is a Group, whose data type is Product. For the Data Source of that Group, we can only show one Product (since it’s a Group). When two Products have the same Record Number, we only want one Product to be displayed anyways, so this is exactly what we want. So the Group’s type of content is Product, and we’re doing a search for Products, setting one constraint, sorting it, and selecting the first item. In Nigel’s example, the constraint is the Product’s CategoryParent is equal to the Current Cell’s Category, shown here in “CategoryParent = Current Cell’s Category”:

In your example the constraint would instead be:“RecordNumberParent = Current Cell’s Record Number”

Since one Product is displayed in a Group within a repeating group, it can only display the data of one Product (that’s why we’re doing a search, creating a constraint, sorting it, and then selecting ‘first item’). The Product Group will display the first item of your choice when two Products have the same ‘RecordNumberParent’, depending upon how you sort the search. You get to decide which Product is shown depending upon how you ‘Sort’ the results of the search. In my example, the first item is displayed in the Product Group depending upon Price (you could do a similar set up with your Quantity field for example):

Then, I think that set up should work the way you intended it so that you don’t have repetition when Products have the same ‘RecordNumberParent’. If any of that was incorrect please let me know, but I think that’s what Nigel did! :slight_smile:

4 Likes

Youuuu sir!!! just nailed down perfectly! I completely got it now. Thanks a lot!!!

1 Like

Awesome!!! :blush: Thank you so much for posting this question!! And thanks again to Nigel! :+1:

1 Like