Insights / RLS in Power BI / Part 6
Part 6 of 20 · Build itPower BI Embedded RLS with CUSTOMDATA
The problem. One report has to serve hundreds of customers, each seeing only their own data, and none of them are Power BI users.
Why. In a normal report you add people to RLS roles by email. In an embedded app there are no Power BI users to add. So instead of identifying the person, you pass the tenant.
How it works.
- The user signs in to your app.
- Your backend looks up which tenant they belong to, from your own database.
- It generates the embed token with the role name and
customDataset to that tenant. - The report loads, and the role filters every query.
-- role TenantFilter
[CustomerId] = CUSTOMDATA()
The rule that keeps it safe: the user never sends their tenant, only their login. Your backend decides the tenant. If the browser could send it, someone changes 147 to 148 and sees another customer's numbers.
Worth knowing:
- Always pass the identity and role in the token. Without them, a report on an RLS model fails to load (service principal), or shows all data (master user account).
- Opened outside your app,
CUSTOMDATA()is blank, so the report shows nothing. - On DirectQuery,
CUSTOMDATA()isn't supported in role rules. Pass the customer ID as the username instead, with[CustomerId] = USERNAME().
Check before go-live
- The tenant ID comes from your backend, never from the browser
- Every embed token includes the role and identity
- A test with two tenants shows each only its own data
Want a second pair of eyes on your own model? The RLS review checks your roles, relationships and workspace access against this checklist, at a fixed price.