Forum Discussion
RLS not working consitently
Hello,
I'm working on applying RLS on my dashboard and I'm not sure why it doesn't work in some profiles. Here's a sample table of what my employee table looks like.
Notes:
- Added PathContains to test the ideal filter if a certain manager takes a took at the dashboard
- EMPLOYEE_ID is not unique as there are times an employee moves to a different manager (see sample below)
| EMPLOYEE_ID | NAME | MANAGER_ID | MANAGER_NAME | PATH | PATHCONTAINS(PATH,"10001") | |
| 10001 | Employee1 | 10019 | Employee0 | 10019|10001 | [email protected] | FALSE |
| 10002 | Employee2 | 10001 | Employee1 | 10019|10001|10002 | [email protected] | TRUE |
| 10003 | Employee2 | 10020 | Employee19 | 10019|10020|10003 | [email protected] | FALSE |
| 10004 | Employee4 | 10020 | Employee19 | 10019|10020|10004 | [email protected] | FALSE |
| 10005 | Employee5 | 10001 | Employee1 | 10019|10001|10005 | [email protected] | TRUE |
| 10006 | Employee6 | 10020 | Employee19 | 10019|10020|10006 | [email protected] | FALSE |
| 10007 | Employee7 | 10001 | Employee1 | 10019|10001|10007 | [email protected] | TRUE |
| 10008 | Employee8 | 10001 | Employee1 | 10019|10001|10008 | [email protected] | TRUE |
| 10009 | Employee9 | 10001 | Employee1 | 10019|10001|10009 | [email protected] | TRUE |
| 10010 | Employee10 | 10001 | Employee1 | 10019|10001|10010 | [email protected] | TRUE |
| 10011 | Employee11 | 10001 | Employee1 | 10019|10001|10011 | [email protected] | TRUE |
| 10012 | Employee12 | 10001 | Employee1 | 10019|10001|10012 | [email protected] | TRUE |
| 10013 | Employee13 | 10001 | Employee1 | 10019|10001|10013 | [email protected] | TRUE |
| 10014 | Employee14 | 10001 | Employee1 | 10019|10001|10014 | [email protected] | TRUE |
| 10015 | Employee15 | 10001 | Employee1 | 10019|10001|10015 | [email protected] | TRUE |
| 10016 | Employee16 | 10001 | Employee1 | 10019|10001|10016 | [email protected] | TRUE |
| 10017 | Employee17 | 10001 | Employee1 | 10019|10001|10017 | [email protected] | TRUE |
| 10018 | Employee18 | 10001 | Employee1 | 10019|10001|10018 | [email protected] | TRUE |
| 10020 | Employee19 | 10019 | Employee0 | 10019|10020 | [email protected] | FALSE |
This table is connected to different tables that point out their works and performance.
Moving along, I have this measure to get their employee ID so that I can run the PATHCONTAINS in RLS:
Get_EMPLOYEEID = CONVERT(CALCULATE(MAX(EmployeeDatabase[EMPLOYEE_ID]), LOWER(EmployeeDatabase[Email]) = LOWER(USERPRINCIPALNAME())), STRING)
And in my Mange Role, I made this one inside the employee table:
PATHCONTAINS([PATH], [Get_EMPLOYEEID]) = TRUE()
This thing works well only if you're not maging people (not a manager) but if you are a manager, it only filters your own data but not the PATH column.
My Wishlist:
- I'm not sure how to fix this one, please help. Ideally the filter in PATHCONTAINS(PATH,"10001") should apply.
- Is there a way to dynamically change the value in PATHCONTAINS? I'll use that column to filter what should be filtered.
- Anonymous2 years ago
Hi Anonymous
You can create the rule directly in rls, you can put the following code to rls.
VAR a = CALCULATE ( MAX ( EmployeeDatabase[EMPLOYEE_ID] ), LOWER ( EmployeeDatabase[Email] ) = LOWER ( USERPRINCIPALNAME () ), ALLSELECTED ( EmployeeDatabase ) ) RETURN CONTAINSSTRING ( EmployeeDatabase[PATH], a )Then test it.
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi Anonymous
You can create the rule directly in rls, you can put the following code to rls.
VAR a = CALCULATE ( MAX ( EmployeeDatabase[EMPLOYEE_ID] ), LOWER ( EmployeeDatabase[Email] ) = LOWER ( USERPRINCIPALNAME () ), ALLSELECTED ( EmployeeDatabase ) ) RETURN CONTAINSSTRING ( EmployeeDatabase[PATH], a )Then test it.
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.