Sub topic 1
What Row-Level Security Does and Why You Need It
Row-level security (RLS) in Power BI limits which rows of a semantic model each person can see. You publish one model and one report, and different people get different slices of the same data. This chapter explains the problem RLS solves, how it works at a high level, and where its guarantees end. Later chapters cover roles, DAX filters, dynamic security, testing, and troubleshooting in detail.
Prerequisites
This chapter assumes you already have the following:
- Basic Power BI Desktop use: you can load data and build a report.
- Star-schema basics: you know fact tables, dimension tables, and one-to-many relationships.
- Beginner-level DAX: you can read columns, comparisons, and simple filter expressions.
- A Microsoft Entra ID (formerly Azure AD) work or school account and access to a Power BI workspace.
You do not need to have created a security role before.
The problem: one dataset, many audiences
Suppose a sales model holds orders for four regions: West, East, North, and South. Each regional manager should see only their own region. The model's owners could solve this in several ways:
- Build four copies of the report, each with a hard-coded filter.
- Build four copies of the model, each loaded with a subset of the data.
- Use a report-level or page-level filter and trust people not to change it.
- Define security on the model itself.
The first three have real costs.
- Copies multiply maintenance. Every change to a measure or relationship must be repeated in each copy, and the copies drift apart.
- Report filters are not security. A viewer who can edit a report, or who connects to the model from Excel or a new report, can remove the filter.
- Hiding a page or visual only hides it. The data is still in the model and can be queried.
RLS takes option 4. The restriction is part of the semantic model, so it applies to every report, dashboard tile, Excel connection, and query that reaches the model through that user's identity.
What RLS is
RLS is a set of rules attached to a semantic model. Each rule is a DAX expression that decides which rows of a table are visible. The rules are grouped into roles. A role is a named container for filter rules, and you assign people or security groups to it.
When a person queries the model, Power BI looks up which roles they belong to and adds those filters to every query. The person never sees rows the filters exclude, and the report does not need to know the rules exist.
Here is the simplest possible rule. It sits on a Region dimension table:
[Region] = "West"A member of the role that holds this rule sees only the rows of the Region table where Region is West. Because of relationships, the filter also reaches the related fact table, so sales totals for that user count only West rows. Chapter 4 of this tutorial covers how that travels through relationships.
How a query is filtered
The next diagram shows the sequence for one request. The same model answers both users, and the engine applies the role filter before the visual's own calculation runs.
Three points follow from this flow.
- The filter is applied at query time. The model still holds all rows in memory, and RLS hides some of them from specific people.
- Each user has their own results. Totals, averages, and counts are all calculated over the filtered rows, so a West manager's "Total Sales" is the West total.
- The filter does not need to appear in the report. You cannot see it on the canvas, which makes it important to test it explicitly.
Where roles live
You create roles and write their filters in Power BI Desktop, in the model. You assign members to those roles after publishing, in the Power BI service. The two steps are separate, and a common early mistake is to define roles and forget to add any members.
| Task | Where | Notes |
|---|---|---|
| Create roles and write DAX filters | Power BI Desktop | Part of the model, so it is published with it |
| Preview a role as a member would see it | Power BI Desktop | Uses View as |
| Add users and security groups to a role | Power BI service | Done on the published semantic model |
| Check a role against the published model | Power BI service | Uses Test as role |
Static and dynamic RLS
There are two main designs, and the rest of the tutorial builds from one to the other.
- Static RLS uses fixed values in the filter, such as
[Region] = "West". You create one role per audience. It is simple, but the number of roles grows with the number of audiences, and every change means editing the model. - Dynamic RLS uses the identity of the signed-in user. A single role looks up who is asking and filters accordingly. The key function is
USERPRINCIPALNAME(), which returns the user's sign-in name, usually an email-style address.
As a preview, a measure like this one shows what the model sees as the current identity:
Current User = USERPRINCIPALNAME()And a dynamic filter on a table with a manager email column looks like this:
[ManagerEmail] = USERPRINCIPALNAME()You do not need to master these yet. The point for now is that the filter can depend on who is asking, which is what lets one role serve everyone.
What RLS restricts, and what it does not
RLS is a row filter on a semantic model. It is useful to be exact about the edges, because the most expensive mistakes come from assuming it does more than it does.
What RLS does restrict
- Rows returned to users who are members of a role and who access the model as viewers.
- Every consumer of that model: reports, dashboards, Analyze in Excel, and other reports built on the same semantic model.
- Aggregates, because they are computed over the filtered rows.
What RLS does not restrict
- Columns. RLS removes rows, not fields. A user can still see every column of the rows they are allowed to see. Restricting columns or tables needs a different feature, object-level security.
- Users with edit rights. In a workspace, people in the Admin, Member, and Contributor roles, and anyone with write permission on the semantic model, are not restricted by RLS. Only the Viewer role is. Chapter 10 covers this in detail.
- Data you leave elsewhere. If a user can open the source database, a file share, or an exported file from before RLS was applied, RLS has no effect on it.
- Access to the report itself. RLS decides which rows a person sees. Whether they can open the report at all is a separate permission.
A first look at the workflow
Here is the sequence you will follow across this tutorial, with the chapter in which each step is covered in depth.
- Decide who should see which rows, and what attribute (region, department, manager) defines the boundary.
- Create a role in Desktop and write a DAX table filter expression on the relevant table.
- Confirm the relationships carry that filter to the fact table.
- Test with View as in Desktop.
- Publish the model, add users or groups to the role in the service, and test again with Test as role.
- Check workspace roles, because they decide whether RLS applies at all.
When RLS is the right tool
Use RLS when all of these are true:
- The audiences share the same measures, visuals, and structure, and differ only in which rows they may see.
- The rule can be written as a condition on data already in the model, or on a mapping you can add to it.
- You want the restriction to hold wherever the model is used, not only in one report.
RLS is a poor fit in other cases.
- Different audiences need different visuals or different calculations. Separate reports are clearer.
- The restriction is on columns, such as hiding a salary field. Use object-level security.
- The source system already enforces row security and you use DirectQuery with single sign-on, in which case the source's own rules may be the better single point of control.
- You need an audit trail of who saw what. RLS filters data. It does not record it.
Common misconceptions
| Belief | Reality |
|---|---|
| "A filter on the report page secures the data." | Report filters can be changed or bypassed. Only a role on the model is enforced. |
| "Defining a role protects the data." | A role does nothing until members are assigned in the service. |
| "I tested it and it works." | If you tested as the model's owner, you tested with a role-exempt identity. |
| "RLS hides columns." | It filters rows only. |
| "One filter on a dimension is enough." | The filter reaches the fact table only through relationships that point the right way. |
Summary
RLS moves access rules into the semantic model, so one model can serve many audiences and each person gets only their permitted rows. Roles hold DAX table filters. You write them in Desktop and assign members in the service. Static roles use fixed values, dynamic roles use USERPRINCIPALNAME(). RLS applies to viewers, filters rows and not columns, and depends on correct relationships and correct testing. The next chapter looks at roles and table filter expressions in detail.
Exercise
A report has a page filter set to Region = West, and the page is hidden from the navigation. A colleague who has Build permission on the semantic model creates a new report from it. Can they see East region rows, and what would you change to restrict them?
Show answer
Yes. A page filter and a hidden page are report-level settings, so they do not apply to a new report built on the model. To restrict rows, define a role in the model with a filter such as [Region] = "West", assign the colleague to it in the service, and make sure they are not in an Admin, Member, or Contributor workspace role and do not have write permission on the model, since those bypass RLS.
Exercise
Name two things RLS does not restrict, and for each say what you would use or check instead.
Show answer
RLS does not restrict columns, so a user sees every column of the rows they may access. Use object-level security to hide columns or tables. RLS also does not apply to workspace Admins, Members, and Contributors, so check workspace role assignments and give people the Viewer role when RLS must apply.