Short answer: row-level security (RLS) filters the rows a user can see through roles with DAX filter expressions. Dynamic RLS uses one role for everyone: a mapping table lists which user may see which region (or customer, or cost centre), and the role filter [Email] = USERPRINCIPALNAME ( ) keeps only the signed-in user's rows, which then filter the facts through relationships. Define roles in Power BI Desktop (Modeling, Manage roles), assign members in the service (Security on the semantic model), and test with View as.
One role per region means one role to maintain per region and a new role for every change. A mapping table moves the rules into data: adding a user is adding a row.
How is dynamic RLS built?
- 1Signed-in userUSERPRINCIPALNAME ( ) returns ana@contoso.com
- 2User Access tablerole filter keeps the rows for ana: North, East
- 3Region tablefiltered to North and East through the relationship
- 4Salesonly North and East rows reach every visual
- Add a table User Access with Email and Region (one row per user and region).
- Relate
User Access[Region]toRegion[Region]. For the filter to flow from User Access to Region, the relationship must filter in that direction: either User Access is on the one side, or set the relationship to both directions with Apply security filter in both directions. - Modeling, Manage roles, new role By user, on table User Access, DAX filter:
[Email] = USERPRINCIPALNAME ( )- Publish, then in the service: semantic model, Security, add users or groups to By user.
How do managers see their team?
Use a parent-child employee table and the PATH functions:
-- calculated column on Employee
Manager Path = PATH ( Employee[Employee ID], Employee[Manager ID] )
-- role filter on Employee
PATHCONTAINS (
Employee[Manager Path],
LOOKUPVALUE ( Employee[Employee ID], Employee[Email], USERPRINCIPALNAME ( ) )
)Each employee row is visible when the signed-in user appears anywhere in its management path: managers see everyone below them.
Which user functions are there?
| Function | Returns | Use |
|---|---|---|
| USERPRINCIPALNAME ( ) | the user principal name, usually the sign-in email | dynamic RLS (the usual choice) |
| USERNAME ( ) | DOMAIN\user in Desktop; the UPN in the service and Report Server | older models |
| USEROBJECTID ( ) | the Microsoft Entra object ID (or SID for SSAS) | mapping by stable IDs |
| CUSTOMDATA ( ) | the CustomData string of the connection | embedding for customers |
| USERCULTURE ( ) | the user's locale, such as en-US | translated labels, not security |
USERNAME behaves differently in Desktop and the service, which is why USERPRINCIPALNAME is preferred. When embedding for customers (app owns data), the app passes an effective identity and roles in the embed token, often with CUSTOMDATA.
Who does RLS apply to?
Microsoft's documentation: RLS roles apply to users with the Viewer role in the workspace, also when they have Build permission on the semantic model. Workspace Admins, Members and Contributors can edit the model and are not restricted by RLS. Share reports with restricted users as Viewers or through an app.
How do you test it?
- In Desktop: Modeling, View as, pick the role and Other user with an email.
- In the service: semantic model, Security, ... next to the role, Test as role, and enter a user.
- Add a card with
USERPRINCIPALNAME ( )to a hidden test page to see what the function returns.
What goes wrong?
- Case and aliases. The UPN may differ from the email users know (an alias, a guest account with #EXT#); map the UPN, and compare in lowercase if needed.
- Filter direction. The mapping filters nothing if the relationship does not carry the filter to the facts; check with View as.
- Admins see everything. Testing as yourself in a workspace where you are Admin shows all data.
- USERELATIONSHIP. It cannot be used on tables with RLS (see relationship functions).
- Performance. Complex role filters run on every query; keep them simple and on small tables.
Where can you check this?
- Microsoft Learn: Row-level security (RLS) with Power BI
- Microsoft Learn: USERPRINCIPALNAME function (DAX)
- Microsoft Learn: Row-level security guidance
Where do you start?
Create the User Access table with three test users, the By user role, and check each with View as before you publish. PATH functions extend it to management hierarchies.