Sub topic 13
Row-level security and source credentials in each mode
This chapter assumes you can build a star schema in Power BI Desktop and write basic DAX. It also assumes you know what a workspace is. It covers two separate security questions that storage mode changes: who a report viewer is allowed to see (row-level security), and which identity Power BI uses to read the source.
Two questions, not one
Every semantic model answers two questions.
- Which rows may this viewer see? Row-level security (RLS) answers this. You define roles in the semantic model. Each role has DAX filter expressions on tables.
- Which identity reads the source? Source credentials answer this. They decide who the database, lake, or warehouse thinks is asking.
Beginners often mix these up. RLS in the model filters query results for the viewer. Credentials only decide whether Power BI can connect and what the source lets that connection read. The storage mode decides when the source is touched (at refresh, at query time, or when columns are loaded). That timing determines which identity the source can see.
How model RLS works
An RLS role holds DAX Boolean expressions on tables. A row is visible only if the expression is true. Filters on a dimension table flow down to the fact table through the relationship, in the same direction as normal filter propagation.
A static role hard-codes a value, such as 'Region'[Region] = "West". A dynamic role compares a column to the signed-in user. It uses USERPRINCIPALNAME(), which returns the user's sign-in name, usually their email address.
Suppose a UserRegion table has UserEmail and RegionId columns. The Region dimension has a RegionId key. This filter on the Region table keeps only the regions assigned to the viewer:
'Region'[RegionId]
IN CALCULATETABLE (
VALUES ( 'UserRegion'[RegionId] ),
'UserRegion'[UserEmail] = USERPRINCIPALNAME ()
)Keep these rules in mind:
- Role members are assigned in the Power BI service, on the semantic model's security settings. Viewers who are not in any role see nothing from the secured tables.
- RLS applies only to users who have read or build access without write access. Workspace Admins, Members, and Contributors can edit the model, so RLS does not restrict them. Test with the Viewer role.
- A user in several roles sees the union of the rows each role allows.
- Use View as in Desktop or in the service to test a role before you publish.
Import mode
Import mode copies data into VertiPaq at refresh time. Credentials matter at refresh, not when someone opens a report.
- The credentials stored on the semantic model's data source (or a cloud connection, or a gateway data source for on-premises data) are used by the scheduled refresh. One identity loads the whole table.
- Report viewers never reach the source. The source cannot tell them apart.
- The only row-level protection for viewers is the model's RLS roles. If the refresh identity can read all rows, the model holds all rows, and any gap in your DAX filters exposes them.
So in Import mode, give the refresh identity the minimum read access the model needs. Do the row filtering in the model.
DirectQuery mode
In DirectQuery, each visual sends a query to the source. Here you have a real choice, and the choice shapes your security design.
Fixed identity (default). The stored credentials run every query. The source sees one account, no matter who opens the report. Model RLS roles still work: Power BI folds the DAX filter into the SQL it generates, as a WHERE condition. You rely on the model to protect rows.
Single sign-on (SSO). For supported sources, such as Azure SQL Database, you can enable Use SSO via Microsoft Entra ID for DirectQuery queries on the data source credentials. Power BI then sends each viewer's own identity to the source. The source applies its own permissions to every query. For on-premises sources, SSO needs a gateway configured for it.
SSO lets you keep security rules in one place, the database. Here is an example of source-side RLS in Azure SQL. It assumes dbo.FactSales has a Region column and dbo.UserRegion maps each user's sign-in name to regions:
CREATE SCHEMA Security;
GO
CREATE FUNCTION Security.fn_RegionPredicate (@Region AS nvarchar(50))
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
SELECT 1 AS allowed
FROM dbo.UserRegion AS u
WHERE u.Region = @Region
AND u.UserEmail = USER_NAME();
GO
CREATE SECURITY POLICY Security.RegionPolicy
ADD FILTER PREDICATE Security.fn_RegionPredicate (Region) ON dbo.FactSales
WITH (STATE = ON);You can combine both layers: SSO with source RLS, plus model roles. Both apply. The viewer sees only rows that pass both.
DirectQuery security has costs:
- With a fixed identity, the source's audit log shows one account for all activity, so you cannot trace a query to a person.
- With SSO, each user's identity opens its own connections and the source may cache less. Watch connection counts.
- A complex role filter becomes complex SQL. A filter that does not fold to the source can slow every visual.
Direct Lake mode
Direct Lake reads Delta tables from OneLake. Credentials affect two steps: who reads the Delta files, and what happens if the model must fall back to DirectQuery.
The data source credential for a Direct Lake model is one of two kinds:
- Single sign-on (Microsoft Entra ID). The viewer's own identity reads the lake. The viewer needs permission on the lakehouse or warehouse, as well as access to the semantic model.
- Fixed identity. A shareable cloud connection supplies the credential. Viewers need access only to the semantic model and report, not to the lakehouse.
Model RLS roles work in Direct Lake. VertiPaq evaluates the DAX filters against the columns it has loaded, with no fallback needed.
There is one gotcha. For Direct Lake on a SQL analytics endpoint, security defined on the endpoint, such as RLS or object-level security on a table, cannot be enforced while Power BI reads the Delta files directly. Queries on those tables fall back to DirectQuery through the endpoint, so the endpoint's rules apply. The model then loses the speed advantage of Direct Lake for those tables. Direct Lake on OneLake reads Delta files directly and does not fall back to the SQL endpoint, so security defined only at the SQL endpoint does not apply there. Check how your lake security is enforced before you rely on it.
Putting it together
| Aspect | Import | DirectQuery | Direct Lake |
|---|---|---|---|
| When the source is read | At refresh | At every query | When columns load into memory |
| Default identity at the source | Stored refresh credential | Stored credential (fixed identity) | Single sign-on or fixed identity, per data source setting |
| Viewer identity can reach source | No | Yes, with SSO | Yes, with SSO |
| Model RLS roles | Yes | Yes, folded into SQL | Yes, evaluated in VertiPaq |
| Source-side security | Not seen by viewers | Applies with SSO | SQL endpoint rules can trigger fallback |
Common errors
- A viewer sees nothing. The user is not in any role, or the dynamic filter compares to an email in a different format, for example a different case or domain. Compare
USERPRINCIPALNAME()output with your security table. - A report author sees every row. Authors with write access bypass RLS. Test as a Viewer.
- RLS works on a dimension but not on the fact table. The relationship direction may not carry the filter. Check the direction. Enable the security filter in both directions only when you need it, because it adds cost.
- DirectQuery SSO fails to connect. The tenant, gateway, or source may not be set up for SSO.
- Direct Lake queries slow down after someone adds endpoint security. Tables with endpoint RLS or object-level security now fall back to DirectQuery.
Exercise
An Azure SQL DirectQuery model uses a fixed identity. Management wants each analyst's activity to be traceable in the database audit log, and wants the database's own RLS policy to apply. What setting changes, and does the model still need RLS roles?
Show answer
Turn on single sign-on (Use SSO via Microsoft Entra ID for DirectQuery queries) on the data source credentials, so each viewer's identity reaches the database. The database then applies its own RLS policy and logs each user. The model needs RLS roles only if you also want a second filtering layer. When both exist, the viewer sees only rows that pass both.
Exercise
A Direct Lake on SQL endpoint model starts running slowly after the data team adds RLS on the endpoint to the sales table. Why, and what are two ways to respond?
Show answer
Power BI cannot enforce endpoint RLS while reading Delta files directly, so queries on that table fall back to DirectQuery through the SQL endpoint. You can remove the endpoint RLS and enforce the rules with model RLS roles, which VertiPaq evaluates in memory. Alternatively, accept DirectQuery for that table and tune it, for example with aggregations.