Slice Filters

I have a users table, which maintains list of users and roles. These roles are more than one and is a enumlist.

User Table

I have a table where i store the menu structure of the app. Each menu item has roles defined.

Roles

I have created slice where i need to filter data based on user roles.

I have used below formula

and([Screen]=“Masters”,in(any(logged_user[role]),[Roles]))

At times this doesnt work.

Please assis.

In what way doesn’t it work?

1 Like

I have created few forms/views. i wish to restrict these based on roles defined for each users. i have created a table for all form/views and use deeplinks to show these. i have added the roles in this table also.

now i want to show or hide the forms based on the user roles and roles defined in the menu table.

for example.

user “Rahul Barve” can access forms assigned to “planning” and “production” since in user master is have assigned him those two.
in the second screenshot, i have tagged forms which can be accessed by which roles.

i hope i was able to make you understand.

i have found some solution right now which is as under:

and([Screen]=“Home”,

IF(
COUNT(logged_user[role])=1,
CONTAINS([roles], ANY(logged_user[role])),
IF(
COUNT(logged_user[role])=2,
OR(
CONTAINS([roles], INDEX(logged_user[role], 1)),
CONTAINS([roles], INDEX(logged_user[role], 2))),
IF(
COUNT(logged_user[role])=3,
OR(
CONTAINS([roles], INDEX(logged_user[role], 1)),
CONTAINS([roles], INDEX(logged_user[role], 2)),
CONTAINS([roles], INDEX(logged_user[role], 3))),
OR(
CONTAINS([roles], INDEX(logged_user[role], 1)),
CONTAINS([roles], INDEX(logged_user[role], 2)),
CONTAINS([roles], INDEX(logged_user[role], 3)),
CONTAINS([roles], INDEX(logged_user[role], 4))))))
)

Maybe this?

ISNOTBLANK(
  INTERSECT(
    logged_user[role]
    [roles]
  )
)

See also:

1 Like

Steve I like it

1 Like

I will check that and revert.

thanks.

1 Like