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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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