Sub topic 3
Static Roles: One Role per Audience
This chapter shows how to build static row-level security (RLS) roles in Power BI Desktop. A static role hard-codes the values a group of people may see. You will create regional roles, check what they return, and learn where this approach stops scaling.
Prerequisites
This chapter assumes you can do the following:
- Load data into Power BI Desktop and build a basic report.
- Read a star schema: fact tables, dimension tables, and one-to-many relationships.
- Write simple DAX comparisons such as
[Region] = "West". - Sign in with a Microsoft Entra ID (Azure AD) work or school account that can publish to a Power BI workspace.
The previous chapter introduced roles and table filter expressions. Here you apply them.
What makes a role static
A role is a named set of DAX filters on tables in the semantic model. A role is static when its filter expression contains a fixed value and does not depend on who is signed in. The expression evaluates the same way for every member.
Here is a typical static filter on a Region dimension table:
[Region] = "West"Read this as: "In the Region table, keep only rows where the Region column equals West." Every member of the role sees West and nothing else. Members of a different role, for example one filtered to "East", see East only.
The model gets one role per audience. If you have four sales regions, you create four roles: West, East, North, and South. You then add the right people to each role in the Power BI service.
Build the example model
The examples use a small star schema:
| Table | Type | Key columns |
|---|---|---|
| `Sales` | Fact | `OrderID`, `RegionKey`, `Amount` |
| `Region` | Dimension | `RegionKey`, `Region`, `Manager` |
| `Product` | Dimension | `ProductKey`, `Category` |
Region[RegionKey] has a one-to-many relationship to Sales[RegionKey]. The filter direction is single, from Region to Sales. This matters because a role filter on Region reaches Sales only by travelling along that relationship.
The next chapter covers propagation in detail. For now, remember the rule: a filter applied to the one side of a relationship narrows the many side.
Why filter the dimension, not the fact
You can place a filter on any table in the model. For static roles, filter the dimension table that holds the attribute people recognise. There are three reasons:
- The dimension has few rows, so the expression is cheap to evaluate.
- The filter flows to every related fact table. If you later add a
Budgetfact table related toRegion, the existing role covers it without any change. - The expression stays readable, because it compares one column to one value.
Filtering the fact table directly, for example Sales[RegionKey] = 1, works but ties the role to a surrogate key that means nothing to the next person who reads it.
Create the roles in Power BI Desktop
Follow these steps for the West role.
- Open the report in Power BI Desktop.
- On the Modeling tab, select Manage roles.
- Select New and name the role
West. - Select the
Regiontable. - In the filter box, enter
[Region] = "West". - Select Save.
Repeat for East, North, and South, changing the value each time. Use role names that describe the audience. A name like Role1 becomes unreadable once you have a dozen.
How a role filter is applied
When a member opens the report, the engine adds the role filter to every query that member runs. Conceptually, the engine evaluates the filter on Region, then lets the filter propagate along relationships before it computes any measure.
Two consequences follow from this:
- The filter is not a visual filter. A member cannot remove it, edit it, or bypass it by changing the report.
- Measures are calculated on the restricted rows. A
SUM(Sales[Amount])for a West member returns the West total, and a grand total in a visual is also the West total.
Combine conditions in one role
A role can filter several tables, and a table filter can use more than one condition. All filters in a role apply together, so a row must pass every one.
For a role that sees West and East, use || (logical OR) on one table:
[Region] = "West" || [Region] = "East"You can also use IN with a list. This form is shorter when the list grows:
[Region] IN { "West", "East" }Filters on different tables in the same role combine with AND. Suppose the role West Hardware has [Region] = "West" on Region and [Category] = "Hardware" on Product. A member sees only sales that are both in the West and in the Hardware category.
| Role | `Region` filter | `Product` filter | Rows visible |
|---|---|---|---|
| `West` | `[Region] = "West"` | none | All West sales, every category |
| `West Hardware` | `[Region] = "West"` | `[Category] = "Hardware"` | West sales in Hardware only |
| `West and East` | `[Region] IN { "West", "East" }` | none | All West and East sales |
Check the result in Desktop
Before you publish, confirm the role returns what you expect.
- On the Modeling tab, select View as.
- Tick the
Westrole. - Select OK.
Power BI Desktop shows a yellow banner that names the active role. Every visual now reflects the West filter. Select Stop viewing to return to the full model.
To confirm that the engine sees the filter, add a card with a simple measure:
Visible Regions = DISTINCTCOUNT ( Region[Region] )Under the West role this card shows 1. With no role active it shows 4. The same check is useful in the service, where the next chapters take you through testing in more depth.
Edge cases to know about
An empty filter result
If the expression matches no rows, members see blank visuals, not an error. A typo is the usual cause. The value "west" matches "West" because DAX string comparison with = ignores case by default, but "Wets" matches nothing. Check the spelling against the actual data.
A filter that returns no table rows because of whitespace
A trailing space in the source data, such as "West ", breaks an exact comparison. Clean the column in Power Query with Trim instead of loosening the DAX.
Roles with no filter
A role that has no filter expression on any table gives its members access to all rows. This is easy to create by accident when you add a role and forget to fill in the expression. Review every role before you publish.
Relationships that block the filter
A filter reaches a fact table only through an active relationship that points toward it. An inactive relationship does not carry the filter, and a many-to-many or bidirectional setup changes the result. If a fact table shows all rows for a regional member, inspect the relationships first.
Fixed values go stale
If a region is renamed from "West" to "Western", the static role silently matches nothing. The role keeps working as written, and nobody sees an error. Keep a short list of the values each role depends on, and review it when the source data changes.
Where static roles stop scaling
Static roles are the simplest approach and are the right choice when the audience is a small, stable set of groups. They become hard to maintain in these situations:
- The number of audiences grows. Fifty sales managers each seeing their own accounts means fifty roles.
- Access changes often. Each change means editing the model in Desktop, republishing, and updating role membership.
- The rule is about the person, not the group, such as "show me only rows where I am the manager".
Dynamic RLS solves these cases with one role that reads the signed-in user's identity. It builds on what you learned here, so the static role remains the reference point.
| Criterion | Static roles | Dynamic role |
|---|---|---|
| Number of roles | One per audience | One for everyone |
| Where access rules live | In the role expression | In a data table |
| Changing someone's access | Edit and republish the model, or change role membership | Edit a row in the table |
| Complexity to build | Low | Moderate |
| Best for | Few, stable audiences | Many users or frequent changes |
Publish and assign
Roles do nothing for your audience until you publish the model and assign members.
- Publish the report from Desktop to a workspace.
- In the service, open the workspace and find the semantic model.
- Select More options (...), then Security.
- Select a role, enter users or security groups, and select Add, then Save.
Assigning a security group to each role is easier to maintain than listing individuals. Adding a new hire to the group is enough to grant access.
Summary of the working model
- A static role is a named set of DAX filters with fixed values.
- Put the filter on a dimension table and let relationships carry it to the facts.
- Several tables in one role combine with AND. Several conditions on one table combine as you write them.
- An empty role is a full-access role.
- Static roles are fine for a few stable audiences and poor for many or changing ones.
Exercise
Your model has a Region dimension related one-to-many to a Sales fact table. You create a role named North with the filter [Region] = "North" on the Region table. A tester reports that a visual built on Sales still shows all rows for North members, and a second report shows the right rows. Name two things you would check in the model.
Show answer
First, check the relationship between Region and Sales. It must be active, and the filter direction must run from Region to Sales. An inactive relationship does not carry the role filter. Second, check whether the tester is also a Contributor, Member, or Admin in the workspace, because those roles bypass RLS. You could also check that the visual's data comes from the related Sales table through the relationship and not from a disconnected copy of the data.
Exercise
A role called West Hardware has [Region] = "West" on the Region table and [Category] = "Hardware" on the Product table. Does a member see West sales in Hardware only, or West sales plus Hardware sales from everywhere?
Show answer
West sales in Hardware only. Filters on different tables in the same role combine with AND, so a row must satisfy both.
Exercise
Write a single filter expression for the Region table that gives a role access to West and East, and state one reason to prefer IN over repeated || conditions.
Show answer
[Region] IN { "West", "East" }. The IN form stays short and easy to read as the list of values grows.