Forum Discussion
dynamic rls
Hi powerbiexpert22,
If you want to apply dynamic RLS you need Security Table and Order Table.
1. Secturity table at leat should have UserEmail | SalespersonID | TeamLeadID | Address columns
2. Make sure
- UserEmail: the login email used in Power BI service.
- SalespersonID: the individual’s own salesperson ID.
- TeamLeadID: their team lead’s ID (can be their own ID if they are a lead).
3. Create relation ship between SecurityTable[SalespersonID] to Orders[salespersonid].
4. Define the RLS Role
- Go to Model View → Manage Roles.
- Create a new role, e.g., SalesRole.
- Apply this filter on the Orders table:
Orders[salespersonid] IN {
SELECTCOLUMNS(
FILTER(SecurityTable, SecurityTable[UserEmail] = USERPRINCIPALNAME()),
"salesid", SecurityTable[SalespersonID]
) }
||
Orders[salespersonid] IN {
SELECTCOLUMNS(
FILTER(SecurityTable, SecurityTable[TeamLeadID] =
CALCULATE(
MAXX(SecurityTable[SalespersonID]),
FILTER(SecurityTable, SecurityTable[UserEmail] = USERPRINCIPALNAME())
)
),
"salesid", SecurityTable[SalespersonID]
)
}5. Tset RLS: Go to Model View → View As Roles.
6. After publishing to Power BI Service:
Go to the dataset settings. Assign real users (email addresses) to the SalesRole defined above.
Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.
Hi ajaybabuinturi ,
I tried mentioned above however i am not getting expected results, please see below screenshots
Security table:
Orders:
Data Model:
Roles: