Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Dynamic Row Level Security Based on Contract

Hi,

I am trying to set up Dynamic Row Level Security for a  large dashboard where each contract should only see their reporting metrcis.  There are multiple people in a contract so I know it needs to be based on email but everyone should see their own contract only.

I have set up a Users Table, Employee Table and obvioulsly data.

 

I cannot seem to get the synxtax right so that I could view each dataset based upon the contract selected only.

Can anyone help?  I know I need two tables that I have to use the Userprincipalname function but I am struggling with the rest of this.

Sales- Desired

NameEmail AddressHire DateContractEmployeeIDUNIQUE CONTRACT AND NAMESales
AA@test.com13-Jun-18ABC1A-ABC10
EE@test.com29-Jul-19ABC5E-ABC125
FF@test.com16-Dec-19ABC6F-ABC50
KK@test.com23-Oct-19ABC11K-ABC75

 

Employee Table

NameEmailAddressHire DateEmployeeIDContractUnique ID
AA@test.com14-Sep-981ABCA-ABC
BB@test.com16-Nov-982CBDB-CBD
CC@test.com3-Oct-143DEFC-DEF
DD@test.com27-Nov-174GHID-GHI
EE@test.com9-Mar-185ABCE-ABC
FF@test.com29-Jun-016ABCF-ABC

 

Users Table

NameEmail AddressHire DateContractEmployeeIDUNIQUE CONTRACT AND NAME
AA@test.com13-Jun-18ABC1A-ABC
BB@test.com18-Jun-18CBD2B-CBD
CC@test.com25-Jan-21DEF3C-DEF
DD@test.com25-Oct-17GHI4D-GHI
EE@test.com29-Jul-19ABC5E-ABC
FF@test.com16-Dec-19ABC6F-ABC
7 REPLIES 7
Anonymous
Not applicable

Data is super sensitive.

In this case, how you you set up the formula in the manage roles?

 

 

In the Employees table:

 

[Email Address]=USERPRINCIPALNAME()

Anonymous
Not applicable

Right but I need everyone from the contract to be able to see it with many emails being associated with the same contract. I guess i am missing something.

 

Depending on the relationship between employees and contracts you can directly link the employees table to the contract table, or you use a mapping table that lists all employee-contract combinations.

lbendlin
Super User
Super User

The usual pitfalls with RLS are 

- you have users with workspace roles above viewer => RLS is ineffective

- your data model links are pointing towards the RLS table => ditto.

 

Other than that USERPRINCIPALNAME works "fine".

 

Personal note:  Do you really need RLS?  Is your data sensitive? Because if not then all you are achieving is to irritate your users.

Anonymous
Not applicable

I don't think I need both tables either but I had seen other examples where that worked.  I can never get the userprincipalname to work.  

Are you really just using one filter on the email? Do you have an example? Thanks!

lbendlin
Super User
Super User

yes, use USERPRINCIPALNAME and apply the RLS on the outermost dimension table of your data model.  

 

What's the reason for having a user table and an employee table?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.