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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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 Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.