How to filter a list of users in a repeating group by a list of data?

I have a repeating group.(Data type is users) Every user has a list of role levels.

(role levels is an option set)

(This is what I want) Current user can select role levels in the app.

image

When the current user selects role levels, it is stored in a custom state.(it’s also a list)

image

So, what I want is, filter the users shown in the repeating group by the selected role levels.

I tried to do this, but I can filter by only one. I want to show the users that have the same roles as selected ones.

Please help!

Edit: I want to show all the users that have at least one of the selected roles.

You should use an advanced filter by comparing this user’s role levels count to the (custom state) selected role levels count and get the ones that have the same count as selected role levels count. Comparing means intersecting. It should be something like this:
This User’s role_levels_candidate intersect with (Wherever the custom state is)'s selected_role_levels : count is selected_role_levels : count

Advanced filter and intersect are demonstrated in this post: Intersect two multi-item fields - #3 by hergin

No, I mean, I want to show all the users that have at least one of the selected roles. If role Junior and role Senior are selected, I want to show all the users that have role junior and role Senior. It doesn’t matter if the users have both roles or only one.

Then it should be This User’s role_levels_candidate intersect with (Wherever the custom state is)'s selected_role_levels : count > 0

1 Like

Thanks. It works but at least one of the roles should be selected to show results… It’s okay!

You can try this method to show results when none are selected.

1 Like

Ohh, thank you!

1 Like

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