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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ashmitp869
Responsive Resident
Responsive Resident

Dynamic RLS with User

Hi All

I tried to make a dynamic RLS per user, but I was unable to make it access according to requirement.

The requriement would be that users 9 or User 1 can access the for respective Project_id - which is table Core_UserProject
User_id 9 should only view the project_id 1 and 5

User_id 7 should only view the project_id  

 

the dax code I made against the Projects Table :

 

 

VAR _Restriction = 
CALCULATETABLE(
    VALUES( Core_UserProject[Project_id]),
    Core_UserProject[Email] = USERPRINCIPALNAME()
)
VAR RLS_Restriction =
SWITCH(
    TRUE(),
    _Restriction = "None", TRUE(),
    Projects[Project_id]=_Restriction,TRUE(),
    FALSE()
)
RETURN
RLS_Restriction

 

 

 

Here are the bases and their respective relationship:

ashmitp869_0-1740959461439.png

 

Projects

ashmitp869_1-1740959603928.png

 

 

Core_UserProject

 

ashmitp869_0-1740959592252.png

 

 

sample file link

 

https://github.com/suvechha/samplepbi/blob/main/sample_info%20-%20security.pbix

 

Thanks

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@ashmitp869 So, normally you would create a user's table that would have the User_id and Email and you would relate that to your Core_UserProject table. Your Core_UserProject table would be related to your Projects table. So you would configure your RLS rule against your Users table using USERPRINCIPALNAME.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@ashmitp869 So, normally you would create a user's table that would have the User_id and Email and you would relate that to your Core_UserProject table. Your Core_UserProject table would be related to your Projects table. So you would configure your RLS rule against your Users table using USERPRINCIPALNAME.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
ashmitp869
Responsive Resident
Responsive Resident

Hi @Anonymous 

@Anonymous 

@v-xul @v-xiaoql @v-xicai @Greg_Deckler @lbendlin Any assistance.
Thanks

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.