Implementing Dynamic RLS in Power BI
Xem Solutions (Formerly Integral BI)
Power Platform Delivery, Handled—So You Can Scale Faster!
Dynamic RLS ensures that only the right people get to see certain data and to keep sensitive information safe and private is very important. It adjusts data based on specific conditions ensuring that the people who meets those specific conditions get access to the data.
What was the reason for implementing dynamic RLS?
How to implement dynamic RLS?
Let’s Open Power BI desktop.
Code
领英推荐
Security[Email]
== USERPRINCIPALNAME ()
|| MAXX (
FILTER (
Security,
Security[Role] = "Super Admin"
&& Security[Email] == USERPRINCIPALNAME ()
),
Security[Role]
)
== "Super Admin"
|| MAXX (
FILTER (
Security,
Security[Role] = "Admin"
&& Security[Email] == USERPRINCIPALNAME ()
),
Security[Role]
) == "Admin"
Now let’s discuss how the code is working
Code
IF (
MAXX (
FILTER (
'Security',
'Security'[Role] = "Super Admin"
&& 'Security'[Email] == USERPRINCIPALNAME ()
),
'Security'[Role]
) == "Super Admin",
TRUE (),
IF (
MAXX (
FILTER (
'Security',
'Security'[Role] = "Access Users"
&& 'Security'[Email] == USERPRINCIPALNAME ()
),
'Security'[Role]
) == "Access Users",
'Form'[Status] == "Access",
IF (
MAXX (
FILTER (
'Security',
'Security'[Role] = "Admin"
&& 'Security'[Email] == USERPRINCIPALNAME ()
),
'Security'[Role]
) == "Admin",
'Form'[Role] = "Admin"
&& 'Form'[Email] = USERPRINCIPALNAME ()
|| 'Form'[Status] = "Access",
TRUE ()
)
)
)
How does the code works?
After applying these steps Dynamic RLS was applied to the report where users get to view report according to their assigned roles.
Conclusion
Using Dynamic RLS in Power BI provides security to data as it filters data according to the applied DAX expression. Dynamic RLS has made it easier to apply security according to the need just like filtering users based on their role. By following these steps, we can make sure that people get to see the data according to their role.
Special thanks to Maham Latif for her contribution to this article.