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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Dynamic RLS with USERPrincipalName

hi guys

 

I am having some trouble with getting Dynamic RLS to work. 

 

I have created a table with all Usernames that I have related to a table with usernames and costcenters. This table is then related to the Dim Costcentertable, which is related to the fact tables. 

 

datamodel.PNG

 

 

 

I have with some borrowing from Radacad put in a second dimension (SeeALL) which I use to overwrite the PrincipalName filter for some individuals who should see all cost centers.

In the RLS filter I have the following DAX code:

If(
MaxX(
Filter(
Users,
'Users'[Username]=USERPRINCIPALNAME())
,'Users'[SeeAll])=0,
max('Users'[Username])=USERPRINCIPALNAME(),
1=1
)

 

The main problem is that it is not working, users on the User list can't get access to see anything in the app.

 

Furtermore the testing in the desktop is not really working either. It seems to only acknowledge myself as a User and everybody else can see everything when I enter their username in "view as roles" function:

 

use as roles.PNG 

 

so why is the testing giving another result (see everything = no filter) than the app in the service (no access, see below:)

 

error report.jpg

I have already tried to skip the above DAX code and just write:

 

Users[Username] = Userprincipalname() This gives me the same result.. which I find quite odd.

 

I have also been through a number of articles about dynamic RLS and also came across the following:

https://angryanalyticsblog.azurewebsites.net/index.php/2016/12/27/dynamic-rls-via-hierarchy-in-power...

In this article a model is available. When I use that model I still can't get the testing to work.. no matter what user I filter in "view as role" it is not filtering anything.

 

What am I doing wrong? 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I found the solution myself. I had two problems in the above. The Dax formula; I needed to take the MAX function out, so that it is now: 

If(
MaxX(
Filter(
Users,
'Users'[Username]=USERPRINCIPALNAME())
,'Users'[SeeAll])=0,
'Users'[Username]=USERPRINCIPALNAME(),
1=1
)

Furthermore I found out that to check it in Desktop I needed to both check "Users" and "Other user"

 

Generally I find it a little frustrating that the documentation on RLS is mainly outdated and still explaining how to assign user on the web service. e.g.: https://docs.microsoft.com/da-dk/power-bi/service-admin-rls

 

..Anyhow.. it works now 🙂

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I found the solution myself. I had two problems in the above. The Dax formula; I needed to take the MAX function out, so that it is now: 

If(
MaxX(
Filter(
Users,
'Users'[Username]=USERPRINCIPALNAME())
,'Users'[SeeAll])=0,
'Users'[Username]=USERPRINCIPALNAME(),
1=1
)

Furthermore I found out that to check it in Desktop I needed to both check "Users" and "Other user"

 

Generally I find it a little frustrating that the documentation on RLS is mainly outdated and still explaining how to assign user on the web service. e.g.: https://docs.microsoft.com/da-dk/power-bi/service-admin-rls

 

..Anyhow.. it works now 🙂

 

Anonymous
Not applicable

I had this problem too. It turns out that I had my SeeAll column with 1's and 0's as a text field and since the DAX expression does not allow comparing Text value with Integer values it gives the error. Changing the SeeAll column to type Integer solved my problem.

Anonymous
Not applicable

Anybody? 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors