- Static row-level security (RLS) roles hard-code a filter. Dynamic RLS matches USERPRINCIPALNAME against a mapping table.
- Store each person's exact User Principal Name (UPN) in the mapping table, or that person sees no data.
- Test with View as in Power BI Desktop and Test as role in the service before you share the report.
- RLS filters rows for workspace Viewers only. It cannot restrict tables or columns.
Row-level security (RLS) lets one Power BI report show each person only the rows they are allowed to see. A regional manager sees their region and a sales rep sees their accounts, all from the same report. This guide builds RLS two ways, a static role and a dynamic role, each with a Data Analysis Expressions (DAX) filter. It then covers testing, publishing, assigning people, and the mistakes that leak data or block it. It is for the report author who needs one report to serve several audiences.
Prerequisites
- A Power BI Desktop file with a working model (a star schema, ideally) and a column you want to filter on, for example Region or SalesRepEmail.
- An import or DirectQuery model. For a live connection to Analysis Services, security is defined in the Analysis Services model.
- A Power BI (Fabric) workspace you can publish to.
- For dynamic RLS, a security or mapping table that links each person's sign-in name to the data they may see.
1. RLS Scope
RLS filters rows for people who hold the Viewer role in the workspace. It does not hide columns. It does not apply to workspace Admins, Members, or Contributors, who have edit permission on the semantic model and see every row. RLS limits what your report audience sees, so plan your workspace roles with that in mind.
2. Static Role
A static role hard-codes the filter. It is easy to read and works well when you have a small, fixed number of audiences. Microsoft documents each field of the role editor in Power BI Desktop.
- In Power BI Desktop, on the Modeling tab, select Manage roles.
- Select New and name the role, for example North Region.
- Under Select tables, pick the table to filter, for example the Region dimension. Under Filter data, build the rule in the default editor, or select Switch to DAX editor and enter:
[Region] = "North"
- Repeat for each region that needs its own role. Select Save.
Static roles multiply. One role per region means editing the model every time a region is added. Dynamic RLS covers that case with one role.
3. Dynamic RLS
Dynamic RLS uses one role for everyone and filters based on who is signed in. It matches that person's sign-in name against a mapping table.
- Make sure your model has a security table with at least two columns: the person's User Principal Name (UPN), which is their sign-in name, and the value they may see, for example Region. Relate it to your data so the filter can flow. RLS filters travel only through active relationships.
- On the Modeling tab, select Manage roles, then New, and name the role, for example Dynamic Region.
- Select the security table, then select Switch to DAX editor. The default editor cannot build a dynamic rule. Enter a filter that compares the column to the USERPRINCIPALNAME function:
[UserEmail] = USERPRINCIPALNAME()
- Select Save. One role now serves everyone: each person sees only the rows mapped to their sign-in name.
In the Power BI service, USERPRINCIPALNAME returns the signed-in person's UPN. It looks like an email address and is often the same as their email, but the two can differ, for example when the email is an alias. Store the value USERPRINCIPALNAME returns. A display name or an old alias will not match, and the person will see nothing. A name change can also change a UPN.
4. Desktop Testing
Test each role in Power BI Desktop before you publish.
- On the Modeling tab, select View as. The View as roles window lists your roles.
- Select a role, then select OK to see the report as that role sees it.
- For dynamic RLS, also select Other user and enter a real UPN from your security table, alongside the role. Desktop shows different results for another user only when the role uses a dynamic rule.
- Confirm the data narrows correctly. To see all rows again, open View as and select None.
5. Role Assignment
The roles travel with the model. You assign people to them in the Power BI service.
- Publish the report to your workspace.
- In the workspace, hover over the semantic model, select More options (...), and select Security. The option appears for people with the Contributor workspace role or higher.
- For each role, add the people or groups who belong in it, by email address or name. Roles accept Microsoft Entra security groups, distribution groups, and mail-enabled groups. Microsoft 365 groups are not supported.
Microsoft recommends mapping security groups to roles where possible, so role membership follows group membership in Microsoft Entra ID.
6. Service Testing
- On the same Security page, select More options (...) next to a role and select Test as role.
- Confirm the report shows only that role's data. Use Now viewing as in the page header to test other roles, a combination of roles, or a specific person.
- Select Back to Row-Level Security when you are done.
For dynamic rules, Test as role evaluates USERPRINCIPALNAME with your own identity. It cannot show what an external guest sees. Include an edge case in your tests, such as someone with no row in the mapping table.
A Viewer assigned to no role typically sees no data. A user assigned to two roles sees the union of both, because roles are additive. Decide what an unassigned or multi-role user should see, and test it. Microsoft's guidance is to give each report user one role that grants everything they need.
7. Common Mistakes
- Audience members with edit roles. RLS does not apply to Admins, Members, or Contributors (see section 1), so give your report audience the Viewer role.
- A mapping table that does not match the UPN. When one person sees no data, check whether their UPN is missing from the security table or entered incorrectly.
- Security filters across relationships. By default, the security filter flows in one direction, even across a relationship set to both directions. The Apply security filter in both directions setting changes that, and Microsoft notes it can slow queries. Turn it on only where your dynamic rule needs it, and test the result.
- Relying on RLS to hide columns. RLS filters rows only. To restrict a table or column, use object-level security.
Final Check
With real assignments in place, have one person from each audience sign in and open the report. Confirm they see their data and only their data. Watch for someone who can see a region they should not, and for someone who sees a blank report. Both point back to the role assignment or the mapping table. For an external guest, this sign-in is the only way to confirm what USERPRINCIPALNAME returns for them.
Next Conversation
If you want a second review of roles, mappings, and workspace access before this report reaches its audience, we're happy to walk through it with you. Reach out through our contact form or give us a call.