How to Create RLS Role in Power BI: Step-by-Step Guide
To create a
Row-Level Security (RLS) role in Power BI, go to the Modeling tab, select Manage Roles, then create a new role with DAX filters on tables to restrict data. After defining roles, assign users to these roles in the Power BI Service to control data visibility.Syntax
In Power BI, RLS roles are created by defining DAX filter expressions on tables. The syntax for a role filter is a DAX expression that returns TRUE for rows the role can see.
- Role Name: A friendly name for the security role.
- Table: The table to apply the filter on.
- DAX Filter: A logical expression that filters rows, e.g.,
[Region] = "West".
DAX
/* Example DAX filter for a role named 'WestRegion' */ [Region] = "West"
Example
This example creates an RLS role called SalesWest that restricts data to only show sales from the 'West' region.
Steps:
- Go to
Modeling > Manage Roles. - Create a new role named
SalesWest. - Select the
Salestable. - Enter the DAX filter:
[Region] = "West". - Save the role and test it using
View as Roles.
DAX
/* Role: SalesWest Table: Sales DAX Filter: */ [Region] = "West"
Output
When applied, users in the SalesWest role see only rows where Region equals 'West'.
Common Pitfalls
- Not testing roles: Always use
View as Rolesto verify filters work as expected. - Incorrect DAX syntax: Filters must return TRUE/FALSE; avoid complex expressions that return other types.
- Forgetting to publish and assign roles: Roles must be published to Power BI Service and users assigned to them.
- Using static filters: For dynamic user filtering, use
USERNAME()orUSERPRINCIPALNAME()in DAX.
DAX
/* Wrong way: filter returns a number instead of TRUE/FALSE */ [SalesAmount] /* Incorrect */ /* Right way: filter returns TRUE/FALSE */ [SalesAmount] > 1000
Quick Reference
| Step | Action |
|---|---|
| 1 | Open Power BI Desktop and go to Modeling tab |
| 2 | Click Manage Roles |
| 3 | Create a new role with a name |
| 4 | Select a table and enter a DAX filter expression |
| 5 | Save the role |
| 6 | Test role with View as Roles |
| 7 | Publish report to Power BI Service |
| 8 | Assign users to roles in Power BI Service |
Key Takeaways
Create RLS roles in Power BI Desktop under Modeling > Manage Roles using DAX filters.
Test roles with View as Roles to ensure correct data restriction.
Publish your report and assign users to roles in Power BI Service to enforce RLS.
Use DAX functions like USERPRINCIPALNAME() for dynamic user-based filtering.
Avoid syntax errors by ensuring filters return TRUE or FALSE values.