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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
captainlaw
Microsoft Employee
Microsoft Employee

RLS with UserName()

Hello Community, 

 

I have two tables, Table A (state, population) Table B (username, state).

Is there a way to setup RLS using username() to reference Table B(username) column to return the value of Table B(state) and join the data to Table A(state)?

 

On a separate but related question - Is there a way to assign a Parameter using UserName()?

 

Your help is much appreciated.

1 ACCEPTED SOLUTION
GilbertQ
Super User
Super User

Hi there, you can most certainly do this.

 

I would suggest reading my blog post, which just gives some explanations around when deploying to the Power BI Service and what to look out for.

 

https://gqbi.wordpress.com/2016/10/03/power-bi-dynamic-row-level-security-things-you-need-to-know-to...

 

And then here is a great blog post by Kasper De Jonge, in which he gives a working example how to get RLS working. And also provides a sample PBIX file. 

 

http://www.kasperonbi.com/power-bi-desktop-dynamic-security-cheat-sheet/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

View solution in original post

5 REPLIES 5
GilbertQ
Super User
Super User

Hi there, you can most certainly do this.

 

I would suggest reading my blog post, which just gives some explanations around when deploying to the Power BI Service and what to look out for.

 

https://gqbi.wordpress.com/2016/10/03/power-bi-dynamic-row-level-security-things-you-need-to-know-to...

 

And then here is a great blog post by Kasper De Jonge, in which he gives a working example how to get RLS working. And also provides a sample PBIX file. 

 

http://www.kasperonbi.com/power-bi-desktop-dynamic-security-cheat-sheet/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

BTW, how come there's not a way to assign username() function within a parameter?  If there's a way, I could restrict data at the import layer instead of at filtering layer to improve performance.

 

Any idea?

Hi there,

 

That is a by design feature and in order for RLS to work correctly, you always have to have the entire dataset. 

 

This ensures that if you have a user who needs access to everything this can be achieved. 

This also ensures that dynamic RLS can be achieved without having to re-create not only the charts but also the dataset.

 

If I understand you correctly you would want to only bring in the data for the specific user?

If that is the case you would then have to have a specific dataset per user, which would increase the size of each individual model.

 

By keeping all the data in one model and leveraging RLS ensures that the data is complete and consistent across the different users.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

You addressed my concern perfectly.  Thank you once again!

Hi

why i don't have (on the join) the option for “Apply security filter in both directions”...?

attach pictureno security join.png

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.