Sub topic 6
Row-level security for recipients
This chapter assumes you can publish a report to the Power BI service, you know what a semantic model is, and you have read the chapter on item permissions. You should also know the difference between Read and Build permission.
What row-level security does
Row-level security (RLS) limits which rows of a semantic model a person can see. You write the rules once. Every recipient opens the same shared report, and Power BI filters the data for each person.
RLS filters data, not access to the report. A person still needs a link, an app, or a workspace role to open the report. RLS then decides which rows appear in its visuals.
The rules belong to the semantic model. They apply to every report built on that model, however the report is shared.
Define a role
You create roles in Power BI Desktop and publish the model to the service.
- In Power BI Desktop, open Modeling and select Manage roles.
- Select New, then name the role, for example
StoreManagers. - Pick a table and add a filter in DAX (Data Analysis Expressions, the formula language of Power BI).
- Save the role and publish the model.
Here is a table filter for a table that has an Email column. It keeps only the rows that match the signed-in user.
[Email] = USERPRINCIPALNAME()USERPRINCIPALNAME() returns the sign-in name of the person viewing the report, usually their email address. One role can therefore serve many people. Each person sees their own rows.
Assign people to the role
A role does nothing until you add members to it.
- In the Power BI service, find the semantic model in the workspace.
- Open its Security page, from the More options menu.
- Select the role and add users or security groups.
- Save.
Prefer security groups to individual names. You then manage membership in one place, and new hires get the right view without a change to the model.
How RLS interacts with roles and permissions
RLS is enforced only for people who have Viewer-level access to the content. Members of the Admin, Member, and Contributor workspace roles can edit the model, so RLS does not restrict them. People with the Build permission on the model can also see its data in their own reports, and RLS still applies to them if they are assigned to a role.
This has a practical effect. If you share by link with someone who has a workspace role above Viewer, they see all the rows. To enforce RLS, share through an app or give people the Viewer role.
Test before you share
Always test a role before you send the report out.
- In Desktop, use View as on the Modeling tab and choose the role.
- In the service, open the model's Security page, select the role's More options menu, and choose Test as role.
- To test a single person, enter their name in the Now viewing as control.
Check at least one user in the role and one user who is not in any role. A user who has no role assigned sees no rows from a secured model.
A related technique: the filter URL parameter
A URL filter is not security. It only opens a report already filtered to one value. The person can remove the filter and see everything the model allows.
https://app.powerbi.com/groups/<workspace-id>/reports/<report-id>/<page-name>?filter=Store/Territory eq 'NC'The format is Table/Field eq 'value'. Use it for convenience, such as a link in an email that opens the North Carolina view. Use RLS when the data must stay hidden.
Common errors
- Recipient sees everything. They hold an Admin, Member, or Contributor role in the workspace.
- Recipient sees an empty report. They are not assigned to any role, or the
Emailvalues in the table do not match their sign-in name. Check for case and domain differences. - Role changes do not appear. Republish the model after you edit the role in Desktop. Assignments made in the service are kept.
Exercise
A colleague opens a report you shared by link. The model has an RLS role with the filter [Email] = USERPRINCIPALNAME(), and your colleague is a member of that role. They still see every row. Name two likely causes and how to fix them.
Show answer
First, they may hold the Admin, Member, or Contributor workspace role, which bypasses RLS. Change their role to Viewer or share through an app. Second, the model may not have the role applied to them, for example if the report uses a different semantic model without RLS. Check the model's Security page and confirm the report uses the secured model.