Sub topic 6
Row-level security for recipients
This chapter assumes you can publish a report to a workspace, know the difference between a report and a semantic model, and have read the earlier chapters on workspace roles and item permissions. You do not need to know DAX beyond reading a simple filter expression.
What row-level security does
Row-level security (RLS) restricts which rows of data a person can see in a semantic model. The report and its visuals stay the same. The rows behind them change depending on who opens the report.
RLS matters for sharing because a link or an app gives people access to a report, and the report reads from a semantic model. Without RLS, every recipient sees every row the model holds. With RLS, you can send one report to a whole sales team, and each person sees only their own region, store, or customer accounts.
RLS is defined on the semantic model, not on the report. That has two consequences:
- Every report built on that model enforces the same rules.
- Sharing a report by link, publishing it in an app, or placing it in a Teams tab all apply the rules the same way.
How it works internally
An RLS setup has three parts.
- A role is a named set of filter rules, created in Power BI Desktop.
- A table filter is a DAX expression on one table in the role. It must evaluate to true or false for each row. Rows where it is false are hidden.
- Members are the people or groups assigned to the role in the Power BI service.
When a member opens a report, the service evaluates the role's filters against the model. The filters propagate along relationships, so a filter on a dimension table also limits the related rows in the fact tables, following the relationship's filter direction.
Dynamic RLS with the signed-in user
You can write one fixed role per group, such as a "North Carolina" role with [Territory] = "NC". That approach gets hard to maintain as groups multiply.
The alternative is dynamic RLS. A single role compares a column in the model with the identity of the person viewing the report. Suppose a table has an Email column. This table filter keeps only the rows that belong to the signed-in user:
[Email] = USERPRINCIPALNAME()USERPRINCIPALNAME() returns the user principal name (UPN) of the viewer, which is usually their sign-in email address. Each recipient of the shared report sees only the rows whose Email value matches their own UPN.
A typical design uses a small security table, with columns such as Email and Territory. The table is related to the dimension table that holds the territories. You apply the filter to the security table, and the relationship carries it to the data. This design lets you add or change access by editing rows of data instead of editing the role.
Dynamic RLS has some requirements:
- The values in the column must match the UPN exactly. A value stored as
[email protected]works because DAX string comparison with=is not case sensitive, but a different alias or a typo will not. - The model must be filtered by that column through a relationship that allows the filter to flow. Check the cross-filter direction.
- Anyone who should see data must have a matching row. People with no matching row see nothing.
Creating and assigning a role
You create the role in Power BI Desktop and assign people in the service.
- In Power BI Desktop, open the Modeling tab and select Manage roles.
- Create a role, for example
ByUser. - Select the table, then enter the DAX filter, for example
[Email] = USERPRINCIPALNAME(). - Save the role and publish the model to a workspace.
- In the Power BI service, open the workspace, find the semantic model, and open its Security page from the more options menu.
- Add people, or better, security groups, to the role.
Use View as in Desktop (Modeling tab) and in the service (Security page, more options on the role) to test the role before you share. In Desktop, you can view as the role alone, or as a specific user by typing their UPN. Testing with a real recipient's UPN is the fastest way to confirm the Email match.
Who RLS applies to
This is the most common source of confusion for people who share content. RLS does not apply to everyone who can open a report.
| Person's access | Does RLS filter their view? |
|---|---|
| Viewer role in the workspace, assigned to an RLS role | Yes |
| Read access through a share link or direct access, assigned to an RLS role | Yes |
| App audience member, assigned to an RLS role | Yes |
| Admin, Member, or Contributor in the workspace | No. These roles can edit the content, so RLS is not applied. |
| Anyone with Write permission on the semantic model | No |
| Viewer with no RLS role assigned, when roles exist | No data is shown |
The practical rule is this: to enforce RLS on someone, give them a way in that does not include edit rights, and assign them to a role. If you add a colleague as a workspace Member to "help them see the report," you have removed their RLS filtering.
Build permission on the model is a related gotcha. Someone with Build can create new reports on the model. RLS still applies to them, but they can query all the data their role allows, in any shape. Treat Build as a data access grant, not as a view-only right.
RLS in the sharing methods
RLS is evaluated against the viewer's identity, so it works across the sharing methods from this tutorial.
- Links. A person who opens a link signs in, and the service applies their role. Users who reach the report through a link need Read access on the report and, for a report on a separate model, Read access on the model. Without a role assignment, they see nothing.
- Apps. App audiences control which reports a person sees. RLS controls which rows they see within those reports. The two are independent and can be used together. An audience cannot replace RLS.
- Teams. A Power BI tab or a chat share opens the same report. The viewer's identity is the one they use for Teams and Power BI, so the same role applies.
Filters in a report URL are a different thing. A URL such as this one opens the report with a filter already set:
https://app.powerbi.com/groups/<workspace-id>/reports/<report-id>/<page-name>?filter=Store/Territory eq 'NC'This is a convenience for the person who follows the link. It is not a security boundary. Anyone can remove the filter in the report or edit the URL. Use RLS when the rest of the data must stay hidden, and use the URL filter when you only want to start the recipient on a useful view.
Limits and failure modes
- Roles on shared semantic models. If a report in one workspace uses a model from another, RLS rules are enforced by the model, so they must be managed on the model's workspace.
- Group membership. Assign security groups to roles instead of individuals. Mail-enabled and Microsoft 365 groups can work for sharing, but check which group types your tenant supports for role membership.
- Empty results. A recipient who sees a blank report usually has a role but no matching rows, or has no role at all. See the troubleshooting chapter for a checklist.
- Performance. Complex filters, such as those that call
LOOKUPVALUEon large tables for every row, slow every query for every user. Prefer a security table with a relationship. - Connection type. Import and DirectQuery models define RLS in the model. Live connections to Analysis Services use the roles defined in that service instead. Defining roles in Desktop does not apply to them.
- Not for hiding columns. RLS removes rows, not columns. To hide sensitive columns, use object-level security.
Checklist before you share
- Define the role and filter in Desktop, using a security table where possible.
- Publish, then add groups to the role on the semantic model's Security page.
- Test with View as for at least two different users, including one with no match.
- Make sure recipients are Viewers, app audience members, or have link-based Read access, not Contributor or above.
- Share the report by link, app, or Teams.
Exercise
A report is shared with a manager by link. The semantic model has a role with the filter [Email] = USERPRINCIPALNAME(), and the manager is assigned to the role. The manager complains that they see every region's data. Their workspace role is Member. What is the likely cause, and what is the fix?
Show answer
Workspace Admin, Member, and Contributor roles can edit content, so RLS is not applied to them. The manager sees all rows because of the Member role. To enforce RLS, remove them from the workspace roles (or lower them to Viewer) and give them access through a link, an app audience, or the Viewer role, while keeping them assigned to the RLS role.
Exercise
You share a link whose URL ends in ?filter=Store/Territory eq 'NC' with a colleague who should only ever see North Carolina data. Is this enough? What would you do?
Show answer
No. A URL filter only sets the starting view. The colleague can edit the URL or clear the filter in the report and see other territories. Define an RLS role on the semantic model, for example a filter on Territory or a dynamic filter such as [Email] = USERPRINCIPALNAME() with a security table, assign the colleague to it, and make sure they have only viewing access.