Sub topic 13
Troubleshooting common RLS problems
This chapter assumes you can build static and dynamic roles, you know how a security mapping table filters a fact table through relationships, and you have tested a role with View as in Desktop. Most RLS faults fall into two groups: users see nothing, or users see too much. Work through them in order, starting with what the model thinks the user's identity is.
A systematic approach
Check these four things first, in this order:
- Which identity does the model see?
- Does the role filter return any rows on the table where it is defined?
- Does that filter reach the fact table?
- Is the user in the role, and does a workspace role bypass it?
To check identity, add this measure to the model and show it in a card while testing a role:
Current User = USERPRINCIPALNAME()If the card shows an unexpected value, fix the identity or the mapping data before you touch the DAX.
Empty reports
An empty report means the role filter matched no rows for that user. Common causes:
- Identity mismatch. The mapping table holds
[email protected], butUSERPRINCIPALNAME()returns a different sign-in name, such as one with another domain. Compare the two values character by character. - Wrong function.
USERNAME()can return a domain and user name in Desktop, whileUSERPRINCIPALNAME()returns the sign-in name. UseUSERPRINCIPALNAME()with email addresses. - Spaces or case differences. Trailing spaces in the mapping table cause silent misses. Clean the column in Power Query with Trim.
- User missing from the mapping table. A user in the role but absent from the table sees no rows. This is correct behavior, not a fault.
- No relationship. The filter works on the dimension but never reaches the fact table, so visuals built on facts show blanks or unfiltered totals depending on the design.
A dynamic filter that you can read against the mapping table looks like this:
[Region] IN CALCULATETABLE (
VALUES ( Security[Region] ),
Security[UserEmail] = USERPRINCIPALNAME ()
)In this expression the Security table is not filtered by the role, so the lookup returns the rows for the current user. If you also place a role filter on Security itself, the lookup can behave differently.
Users see too much data
Over-exposure is more serious than an empty report. Check these causes:
- Workspace role. Members of the Admin, Member and Contributor roles, and anyone with Build or edit rights on the model, are not restricted by RLS. Only Viewers are. Test with a real Viewer account.
- Several roles. A user in more than one role sees the union of the rows each role allows. One broad role cancels a strict one.
- Filter on the wrong table. A filter on a fact table does not restrict the dimension tables, because filters flow from the one side to the many side.
- Missing filter direction. If the mapping table connects to the model with a relationship that does not propagate to the table you want to restrict, nothing is filtered.
- Not assigned. A user who is in no role, but has a workspace role that bypasses RLS, sees everything.
Other checks
| Symptom | Likely cause | Fix |
|---|---|---|
| Works in Desktop, empty in the service | Users not added to the role in the service | Add users or security groups to the role |
| Works in View as, fails for one person | Their sign-in name differs from the mapping value | Check `Current User` and correct the mapping row |
| Role change has no effect | Model was not republished | Publish again, then re-test |
| Whole tenant sees the data | Report shared with Build permission or user is a Contributor | Review workspace and dataset permissions |
Exercise
A user was added to the dynamic role and the mapping table contains her email address. She still sees an empty report, while View as in Desktop with her name works. What two things do you check first?
Show answer
Check which value USERPRINCIPALNAME() returns for her in the service (show it with the Current User measure), and compare it with the mapping table value for differences such as domain, spaces or case. Also confirm that she is added to the role in the service and that the latest model version is published.
Exercise
A regional manager sees every region even though her role filters Region. Name two likely causes.
Show answer
She has a workspace role that bypasses RLS (Admin, Member or Contributor), or she belongs to another role that allows more rows, since multiple roles combine as a union.