Implementing Row-Level Security in Power BI: Ensuring Data Privacy and Access Control

Implementing Row-Level Security in Power BI: Ensuring Data Privacy and Access Control

In my recent Power BI project, I tackled a common but crucial challenge—establishing secure access to specific data segments for individual users while safeguarding the rest. Using Power BI’s Row-Level Security (RLS), I created targeted data views that allowed only designated users to see relevant information. This setup was critical for ensuring data privacy and precision in reporting, especially when working with diverse user roles and access needs within the organization. Here’s a look at how RLS can help enhance data security and drive tailored insights across teams.

Imagine you’re working with a payroll table and need to restrict access so that each employee only sees their own payroll information, while also allowing their direct manager to view it. Additionally, the Vice President of Sales requires unrestricted access across all payroll data. In the model view, you can observe the relationships between the dimension (DimEmployee) and fact tables (FactResellerSales), typically set up as one-to-many, enabling these precise, role-based access controls.


The dimension (Dim) table is shown below. Notably, each employee record includes both the employee’s email address and their supervisor’s email address, which enables us to set up role-based access based on reporting hierarchies.

To create Row-Level Security, navigate to the Model View, and select Manage Roles from the ribbon.


After clicking the Manage Roles button, an interface will appear where you can set up and configure each role.


On the left-hand side, create a new role, such as Sales Rep. Next, select the DimEmployee table, then switch from the default editor to the DAX editor, where you’ll need to input the following expression:

DimEmployee[EmailAddress] == USERPRINCIPALNAME()        

In this context, DimEmployee[EmailAddress] represents the employee's email in the DimEmployee table, while the function USERPRINCIPALNAME() returns the current user’s email. Similarly, we can create a SalesMng role with a similar setup:

DimEmployee[Supevisor Email] == USERPRINCIPALNAME() || 
DimEmployee[EmailAddress] == USERPRINCIPALNAME()        

For the SalesVP role, there’s no need to set up any restrictions since the Vice President of Sales has full access to all data.

To verify the defined roles, switch to the report view and create a table:


In the report view, navigate to the Modeling menu and select the View as button to open the View as Roles menu. If you don’t specify an email in the Other user field, the system will default to your account. To view the report as a specific employee, enter their email in the Other user field, choose the appropriate role (such as SalesMng or SalesRep), and click OK.



By selecting SalesMng, we will only see David's records.


We will not retrieve any records if we select SalesMng because David is a Sales Representative. Conversely, if we input Amy's email (amy0@adventure-works.com) and choose SalesRep, we will receive the following information:

Thus, she receives information for herself as well as for the employees she manages. Meanwhile, the Sales VP has access to the entire dataset without any restrictions.

In conclusion, implementing Row-Level Security in Power BI is essential for safeguarding sensitive data while providing tailored access based on user roles. By effectively setting up roles like SalesRep and SalesMng, organizations can ensure that employees view only the information pertinent to their responsibilities. This not only enhances data privacy but also fosters accountability within teams. As demonstrated, Power BI offers a robust framework for managing access, allowing leaders, like the Sales VP, to retain comprehensive oversight while empowering individual contributors with the data they need to excel in their roles.


Dmytro Savin

iOS Software Developer | dsavinau@gmail.com

1mo

That’s interesting, Boris. 👍

Mohammed Affan

AI-Powered Business Analyst | Ex - Accenture, Ex - JPMorgan Chase | Python | SQL | Tableau | Data Exploration and Analysis | ETL | AI and Machine Learning Proficiency |

1mo

Fascinating read, Boris! Your approach to implementing Row-Level Security in Power BI is impressive. How do you see this evolving in the future?

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics