Forum Discussion
RLS multiple combination
Hi there,
I would like to implement Dynamic RLS in Power BI but not like Corporate Heirachy manager or report to
The data contain multiple companis and departments and the rolle need to be based on that combination
And my database diagram I have Company table and Department table (I can combine this into one tabe if need it)
How do you approch that scenario?
(I'm thinking TSQL view with string_split() and cross join to generate all possibilities) then do company first and Department second but I need some help.
Like Principal Name Company Department
[email protected] 01|16|51 12|14|22|36
[email protected] 01|51 14|22
[email protected] 55 10
Thanks
Oded Dror
I just remembered that I had to do something strange with my tables which required me to use the OR. For yours, you should be able to just use the following:
- On the company table - Company[PrincipalName] = UserPrincipalName()
- On the department table - Department[PrincipalName] = UserPrincipalName()
If it doesn't work for you I will work up a PBIX file that I can share to demonstrate what I am thinking.
9 Replies
- v-chuncz-msftCommunity Support
Anonymous ,
You may select Split Column By Delimiter > Advanced options > Split into Rows in Query Editor.
- AnonymousNot applicable
Thank you for response,
I was able to create a table based on these combination using TSQL, the issue I'm having is how to set RLS
with multiple column in a table? my table contain company column and department column
Shoud I create a compusite key for uniqness then create a rool based on this key and User Principal Name?
Iv'e try to do RLS on seperate coluns but it seems to not working.
Thanks,
Oded Dror
- jtownsend21Responsive Resident
Anonymous I believe you will need two tables (one for company and one for department), arranged like so:
Principal Name Company [email protected] 1 [email protected] 16 [email protected] 51 [email protected] 1 [email protected] 51 [email protected] 55 Principal Name Department [email protected] 12 [email protected] 14 [email protected] 22 [email protected] 36 [email protected] 14 [email protected] 22 [email protected] 10 Then you need to create the relationships between your fact table(s) (my example below has 2 fact tables) and your two filter tables like the picture below based on the department and company columns.
Then put filters on your company and department tables in the "Manage Roles" (where you input the RLS).
OR([Email] = USERPRINCIPALNAME(), [Email] = USERPRINCIPALNAME())
the exact filter you use in the RLS may vary slightly depending on whether you are using email or some other Id. But this should filter your Company & Department tables which will then filter your fact tables. Side note, you will need to add your users to both groups in your PowerBI service.