Sub topic 11
What happens when a user belongs to several roles
This chapter assumes you can create roles in Power BI Desktop, write DAX table filter expressions, and assign members to roles in the Power BI service. You should also know how a filter on a dimension table reaches a fact table through a one-to-many relationship.
Roles combine with OR
A user can be a member of more than one role on the same semantic model. This happens often. A person may sit in a security group assigned to the West role and also be listed individually in the East role.
Power BI does not intersect the roles. It takes the union of what each role allows. A row is visible if any of the user's roles lets it through. More roles can only show more data, never less.
Suppose a Region table has two roles:
- Role
Westwith the filter[Region] = "West" - Role
Eastwith the filter[Region] = "East"
A user in both roles sees rows for West and East. Rows for North stay hidden, because neither role allows them.
The filters are evaluated per table
The union is applied for each table separately. Think of each role as producing a set of allowed rows per table, and the user gets the combined set.
A role that defines no filter on a table allows all rows of that table. This causes a common surprise. Consider these roles:
| Role | Filter on Region | Filter on Product |
|---|---|---|
| West | `[Region] = "West"` | none |
| Bikes | none | `[Category] = "Bikes"` |
A user in both roles does not see "West bikes only". The West role allows every product, and the Bikes role allows every region. Together the user sees all regions and all products, so the user effectively sees everything.
If you want a user to see only West bikes, put both conditions in one role, one filter on each table. Do not split them across two roles.
-- Role: WestBikes
-- Filter on Region table:
[Region] = "West"
-- Filter on Product table:
[Category] = "Bikes"Inside one role, the filters on different tables combine with AND, because both filters narrow the fact table.
Dynamic roles and several roles
A dynamic role that uses USERPRINCIPALNAME() already serves every user, so a user rarely needs a second role for regional access. If a user is in the dynamic role and also in a static role such as West, the result is the union. The static role can widen what the mapping table allows.
Keep this in mind when you add a convenience role later. A broad role such as AllRegions with no filter at all overrides every other role for its members. Anyone in it sees every row.
-- Dynamic role filter on the Region table
[Region] IN CALCULATETABLE (
VALUES ( Security[Region] ),
Security[UserEmail] = USERPRINCIPALNAME ()
)If a user is in this role and in West, they see the regions listed for them in Security plus West.
Security groups can create overlap you do not see
In the service you can assign a security group to a role. A user then gets that role through group membership. If the same user is in two groups, and each group is assigned to a different role, the user is in both roles, and the union applies.
This means a user's effective access depends on directory membership, which can change without anyone opening Power BI. Check group membership in Microsoft Entra ID when a user reports seeing more data than expected.
Checking the combined result
Test the combined behavior before you publish. In Power BI Desktop, choose View as and tick more than one role at the same time. Desktop applies the union, and you can confirm what a member of both roles sees. In the service, Test as role also lets you select several roles.
Remember that testing with a workspace Admin, Member, or Contributor account can mislead you, because those roles bypass RLS on the semantic model that they can edit. Test with a viewer account or with the testing tools above.
Exercise
A role named West filters the Region table to [Region] = "West" and has no filter on Product. A role named Bikes filters the Product table to [Category] = "Bikes" and has no filter on Region. A user belongs to both roles. What does the user see, and how would you change the design so the user sees only West bikes?
Show answer
The user sees all regions and all products, because each role allows everything on the table it does not filter, and the roles combine with OR. To show only West bikes, create one role with both filters, [Region] = "West" on Region and [Category] = "Bikes" on Product, and remove the user from the two separate roles.