Filtering a repeating group by checking if a group from the repeating group has at least 1 element from the filter list

So, i have a repeating group of users which I’m trying to filter. I have the filter buttons on top of the users table and by pushing these buttons, they do a drop down and you can select multiple filter options, for example, if i push roles, i can select: designer, developer, etc. By doing so I create a list of role filters, which contains the texts of the filters the user chooses.

I know for a fact that the list is there, containing all the filter texts the user chooses, however my problem is the following, I’m trying to use this filter list to filter the repeating group. The repeating group is made of users as i said, and they have a roles table, which basically is a list of roles the user has/is. What I’m trying to accomplish is simple, I want to check if there is at least a single role from the users that is present in the roles filter list, because if there is, i want the user to be displayed, if not, well i don’t want the user to be there. I tried to add a constraint, but i didn’t see any operators which do: “if users user’s roles has at least 1 role text which matches a role from the roles filter”.

Can somebody help me out with this issue?
Thanks <3

So if your User has a field role and you would like to filter the repeating group using a dropdown (single value choosing), all you need is to add constraint role = dropdown's role value in your Do a search expression. If the field role within User is a list of roles - role contains dropdown's role value

Thank you for the reply. I really appreciate the time you’re giving to address my issue.
The thing is, it’s not single value choosing, you can actually choose multiple filters at once, so it’s a list of texts(filters).

As you can see, i chose 2 roles and i want those users displayed who have at least 1 role from the chosen filters

If your RG data type has a list of roles per thing, then you can use the intersect with operator:

I’m using nonsense in my screenshot to show you the structure; replace the things with what you use in the app. This RG data type’s roles intersect with user selected roles list:count is not 0

So you intersect with the selected roles and check if the count is not zero. If it’s not, then include it.

Another way to look at it is:

Item #1 in RG has roles: X, Y

User wants to see all items that are : X or Z

If you intersect those two lists, then X remains. That means the resulting list will have a count of one, which means it will be displayed in your RG.

image

If your RG data type has one role per thing, then you should be able to use the “is in” search constraint:

image

It can get weird when you need to do “is in this” OR “is in something else”. Then you need to use filters or merge multiple searches together.

1 Like

Hello,
Thank you for your reply.
I do have one question tho, how do i use the advance feature? Does it not come with the free plan?

Hi there,

If you first select “Filtered” in your main Data Source, in the filter popup you would then select “Advanced”. In using the screenshot from @julian5 example above:

Thank you for the reply <3.
One last question, everything worked fine, except for the fact that when the page loads, nothing is present. The filtering process works as it should because i copied it exactly how Julian had it and i thought count is not 0 would do the trick. I even checked the ignore empty constraints checkbox but for some reason until i filter something, nothing shows up

On the main Data Source, I’d also see if Ignore Empty Constraints is checked, and if not, try checking it there as well.

I did have it on both the main data source and the filtered one :confused:
Still no users displayed till i filter them


Hmm certainly an interesting issue! Off the top of my head I assume this is because the constraint is an Advanced Filter with a yes/no condition, and not an input itself. Once you select some filters but then deselect them all, is your repeating group staying populated or does it go blank again?

The repeating group filtering process works exactly as it supposed to, so the answer is, it goes blank, but that’s the problem. By default, when no filters are selected, it shouldn’t be blank :confused:
This is my app here, Roles, skills, seniorty and languages filters are working and until you don’t choose all of the filters, the filtered user/s won’t appear. I’m guessing that the filters i’ve added aside from roles work just the same as the roles itself, so it won’t display the users until their filtered, so unless you pick all the above filters mentioned, you won’t get your user/s.

I’m taking a look now - can you give me some filters to try that would bring up results?

yes, of course. Pick first for every filter from roles to languages.

What happens when you change your Advanced filter to:
This Emp's Roles intersect with Group L's ChosenFilters is not empty

(instead of ‘Count is not 0’)

It won’t let me do that :confused:

1 Like

Ok here’s something else to try - have the data source just be ‘Search for Emps’ (no Filter). Have a condition on the Data-Content Repeating Group that when Group M’s ChosenFilters:count is not 0, Data source = Search for Emps: filtered. And then on the Filter add your Advanced filter as written.

1 Like

I just tested this approach and found it successful - I hope you do too!

1 Like

You have been a gem msgiblin, thank you very much :heart: This community needs more people like you :heart:

There is just one issue :frowning:
For some reason the filtering doesn’t work unless i choose all of the filters when they should be working both independently and all together.

Here, i have 2 constraints for skills and roles the way you told me, it worked fine for only a single one however for 2, the filtering won’t work unless i choose the filters from both groups:

result(1st picture: no filters chosen)

2nd picture, only roles filter chosen and it’s empty cuz it wants values for skills as well :confused:

chose both roles and skills:

I think it should see the count is not 0 in the constraints itself, but it doesn’t but sees it however when i write it as a condition. Super weird.

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