Sub topic 13
Troubleshooting common RLS problems
This chapter assumes you can build static and dynamic roles in Power BI Desktop, that you understand one-to-many relationships in a star schema, and that you have read the earlier chapters on testing roles, assigning members in the service, and workspace role bypass. It gives you a repeatable way to diagnose the two symptoms you will meet most often: a report that shows nothing, and a report that shows too much.
A diagnostic routine
Most RLS problems come from a small set of causes. Check them in a fixed order instead of guessing. The order below goes from the cheapest check to the most expensive one.
Problem 1: the report is empty
An empty report is the safer failure, because the model returns no rows instead of the wrong rows. The filter expression is evaluated, and it returns nothing for this user. Work through these causes.
The user is in no role
When a semantic model has at least one role, a user who is not a member of any role and who does not bypass RLS sees no data. Open the model's security settings in the service and confirm that the user, or a security group that contains the user, is listed under a role.
The sign-in name does not match the mapping table
Dynamic roles compare USERPRINCIPALNAME() to a column of text. The comparison fails when the values differ in any way you can't easily see.
- The mapping table stores a display name, an alias, or an old email address instead of the user principal name (UPN).
- The user signs in with a UPN that differs from their email address. This happens often after a company renames a domain.
- The stored value has leading or trailing spaces.
- The value is a guest account, such as
name_partner.com#EXT#@yourtenant.onmicrosoft.com.
DAX string comparison with = ignores case, so capitalization is not the cause. Spaces and different spellings are.
To see what the model receives, add this measure to the model and place it in a card visual while you test the role.
Current User = USERPRINCIPALNAME()Then compare the value in the card with the value in your mapping table. If you copy both into a text editor, hidden spaces become visible.
The filter does not reach the fact table
A role filter applies to the table where you define it. It reaches other tables only through relationships, and only in the direction that the relationship propagates filters. In a star schema, a filter on a dimension flows to the fact table because the dimension is on the one side of a one-to-many relationship.
Consider a Security table that maps users to regions.
[Region] IN CALCULATETABLE (
VALUES ( Security[Region] ),
Security[UserEmail] = USERPRINCIPALNAME ()
)This expression belongs to the Region dimension. It works only if Region relates to the fact table. If the relationship is missing, inactive, or based on the wrong column, the fact table is unaffected. Depending on the model, you then see either all the sales rows or no connection between the filtered dimension and the measures. Open the model view and check that the relationship line exists, that it is solid (active), and that it joins the columns you expect.
The Security table itself does not need a relationship to the model for the expression above. The CALCULATETABLE pattern looks up the user's rows inside the Security table directly. Keep the Security table hidden from report authors, and do not let a relationship from it filter your dimensions in ways you did not plan.
Data type mismatches
If the key on the dimension is a number and the key in the mapping table is text, the comparison fails and the role returns nothing. Make both columns the same data type in Power Query.
Problem 2: the user sees too much data
Over-exposure is the more serious failure. Check these causes first, because they account for most cases.
The user has a workspace role that bypasses RLS
RLS filters are not applied to people who have edit permission on the semantic model. In a workspace, the Admin, Member, and Contributor roles all have it. A user in one of these roles sees all the data, no matter which roles they were assigned. The Viewer role does not bypass RLS.
| Workspace role | RLS applies? |
|---|---|
| Admin | No |
| Member | No |
| Contributor | No |
| Viewer | Yes |
The same is true for anyone who has Build permission with write access on the semantic model through another route. People who own the semantic model also see everything. When a tester says "RLS does not work for me", check their workspace role first. If you are the author, you are an Admin or Member, so you will always see all rows when you open the report normally.
The fix is to give report consumers the Viewer role in the workspace, or to share an app or report with them instead of adding them to the workspace.
The user belongs to several roles
When a user is in more than one role, Power BI combines the roles with a union. The user sees the rows that any of the roles allows. A user who is in both West and East sees both regions. This is the expected behavior, but it surprises people who think a second role narrows the first. If someone sees more than you intended, list all the roles that include them, including roles reached through security groups.
The filter direction reverses the flow
A dimension filter reaches the fact table by following the relationship from the one side to the many side. If you want a role on a fact table to limit a dimension, the filter does not travel backward unless you turned on the option to apply security filters in both directions. Use that option with care. A bidirectional relationship can produce ambiguous filter paths and slow queries, and it can expose rows through a path you did not plan. Prefer to put the role filter on a dimension and let it flow down.
The role filter is too permissive
Check the expression. The common mistakes are:
- Using
TRUE()or a filter that is true for every row, left over from testing. - Comparing a column to itself.
- Defining the filter on the wrong table, so the table you meant to secure is unfiltered.
Read the expression aloud as a sentence: "show rows of this table where ...". If the sentence does not match your intent, rewrite it.
Problem 3: the role works in Desktop but not in the service
The checks in Desktop and in the service use different mechanisms, so a pass in one does not prove a pass in the other.
- View as in Desktop only simulates a role on your local file. It does not test who is assigned to the role.
- Test as role in the service tests the published model, and it lets you choose a role or a specific user.
If the report works in Desktop, publish it and then use Test as role in the service. When you do, pick Now viewing as with a specific person, which shows what that person sees given all of their roles. If the person sees data you did not expect, the cause is their membership, not the DAX.
Also remember that republishing a model from Desktop keeps the role definitions in the file but may not keep the member assignments, so confirm membership after each publish.
Problem 4: the report works for some users and not for others
Compare a working user and a failing user, one factor at a time.
- Check each person's workspace role.
- Check each person's role membership, including group membership.
- Check the value of
USERPRINCIPALNAME()for each person. - Check their rows in the mapping table.
- Check whether either person signs in as a guest.
A pattern appears quickly. For example, all users whose email domain changed see empty reports, or all users who are members of a certain group see too much.
A practical checklist
| Symptom | First check | Likely fix |
|---|---|---|
| Empty report for one user | Role membership in the service | Add the user or a group that contains them |
| Empty report for many users | Mapping table values | Correct emails, trim spaces, match the UPN |
| Empty report, filter looks right | Relationships | Make the relationship active and on the right columns |
| Too much data for the author | Workspace role | Expected; test with Viewer or Test as role |
| Too much data for a consumer | Workspace role and multiple roles | Change to Viewer, review all roles |
| Works in Desktop, not in the service | Membership after publish | Reassign members and retest |
Prevention habits
- Keep a test account with the Viewer role and use it for every release.
- Test at least one user with each role, one user with two roles, and one user with no role.
- Keep the mapping table in one place, with a single column of UPNs and no free-text names.
- Document which security groups map to which roles.
- Review the workspace role list on a schedule. Someone promoted to Contributor can bypass every role you built.
Exercise
A regional manager reports that every visual in the sales report is empty. The role uses [Region] IN CALCULATETABLE ( VALUES ( Security[Region] ), Security[UserEmail] = USERPRINCIPALNAME () ). The manager is a Viewer in the workspace and is a member of the role. Name two things you would check next, and how you would check each.
Show answer
First, check that the manager's sign-in name matches the Security table. Add a Current User = USERPRINCIPALNAME() measure, show it in a card while using Test as role for the manager, and compare the value with the UserEmail column, looking for different domains, aliases, or extra spaces. Second, check that the Region dimension has an active one-to-many relationship to the fact table on the correct columns, and that the data types of the Region values in the Security table and the dimension are the same.
Exercise
You build a role, open the published report as the workspace owner, and see every region. Does this mean the role is broken? What should you do to test it?
Show answer
No. Workspace Admin, Member, and Contributor roles bypass RLS, and the owner has edit permission on the model, so they see all rows. Test with Test as role in the service, choosing the role or a specific user, or sign in with a separate account that has the Viewer role.