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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Dynamic row level security not working on service

Hi All I really need help before I need to put a static process in place. I have spent days researching trying to get it to work. 

 

Link to test file: Test data file

 

I have a test data table that looks like this with sensitive survey data (cut down version):

 

ResponsesSurveysShort_QuestionYearTerm_AllFaculty_School_CleanCourseCode_Description
2010Q120202020 SummerFaculty 4School 4Course 1
2010Q220202020 SummerFaculty 4School 4Course 1
2010Q320202020 SummerFaculty 4School 4Course 1
2010Q420202020 SummerFaculty 4School 4Course 1
2010Q520202020 SummerFaculty 4School 4Course 1
1012Q420202020 SummerFaculty 1School 1Course 2
1012Q520202020 SummerFaculty 1School 1Course 2
30060Q120202020 SummerFaculty 3School 2Course 3
30060Q220202020 SummerFaculty 3School 2Course 3
30060Q420202020 SummerFaculty 3School 2Course 3
30060Q520202020 SummerFaculty 3School 2Course 3
59029Q120202020 SummerFaculty 2School 5Course 4
59029Q220202020 SummerFaculty 2School 5Course 4
59029Q320202020 SummerFaculty 2School 5Course 4
59029Q520202020 SummerFaculty 2School 5Course 4
70013Q120202020 SummerFaculty 2School 3Course 5
70013Q220202020 SummerFaculty 2School 3Course 5
70013Q320202020 SummerFaculty 2School 3Course 5
70013Q520202020 SummerFaculty 2School 3Course 5

 

I have a users table like this:

School_CleanUsername
School 1user1@test.com
School 2user2@test.com
School 3user3@test.com
School 4user3@test.com
School 5user5@test.com

 

I will put the real emails in before I test in the service. 

 

I am trying to ensure that user1 sees all data for School 1 etc, but nothing I do works when it gets into services. 

have added the emails to the role correctly in security within the service. 

 

I have implemented roles and it all works fine in desktop when I view as role, however it is not working in the desktop no matter what I do. Just the header of the table is shown with no data. I

I have tried multiple approaches, the latest one includes the following code:

CONTAINS('SECURITY (2)', 'SECURITY (2)'[Username], USERPRINCIPALNAME(), 'SECURITY (2)'[School_Clean], 'TEST'[School_Clean])

 

I really need some help!

7 REPLIES 7
Anonymous
Not applicable

@Anonymous 
Once you have a list of email address of users, you should try a simple code in RLS:

 

Username = Userprinciplename()

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

Thanks yes I have tried that on the data table, I can 'View as' on the desktop and everything works as expected. And when I publish to the service, add the email addresses to the roles, and then test as role, I cant see anything. Its just a bit weird! 

Anonymous
Not applicable

@Anonymous 

Your dynamic RLS should have worked properly, although you cannot see value with test as role.

With my test, I also get blanks with "test as roles". To make it work properly you need to enter the selected person. Otherwise power bi service cannot determine whose view do you want among many users so returns blank.

selete person.JPG


Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi Paul, 

 

Yes I did enter the name of the person in. Still cant see anything.

jdbuchanan71
Super User
Super User

@Anonymous 

Have you added the users to the roles in the service?

Once you have published, on PowerBI.com you go to datasets > security and add users to the role.

jdbuchanan71_0-1595450941547.png

jdbuchanan71_2-1595450983003.png

Keep in mind that if a user is a member of the workspace the RLS will not apply to them.

An article that might help some: https://docs.microsoft.com/en-us/power-bi/admin/service-admin-rls

Anonymous
Not applicable

Hi Yes, I have added the role in the service and tested as that role, when I test as role this is where the table headers appear but no data. 

Anonymous
Not applicable

Hi, if you happen to still be working on this two years later, or for anyone else that gets this as the first result:

The Usernames might not be what you think it is. In a medium article I found this hint:
"

Identify user in hierarchy

User Principal Name function, USERPRINCIPALNAME(), is the main method for identification. Note that this function return different values in desktop and in online service. The online name is what matter during RLS execution."

I had the same problem, and I was using first.last@companyname.com, but the actual IDS in Power BI were companyid@companyname.com . So if you test first.last@companyname.com in desktop it will work, but when you test the individual in live, it will use their ID email, and it won't work.

Hope this helps someone!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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