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
Charu
Post Patron
Post Patron

Dynamic RLS role creation based on Login name

 

Hi Everyone,

Based on the user logged in for them their own record and the person who is reporting to the logged in user those details also should display 

How to compare the logged in username in the Manage role creation?

For example:

Employee_ID | Employee_Name | Reporting_TO_Name | Email_address

1                     | John                       |   Ajay Kumar                | john@domain.com

2                     | William                   |  Ajay Kumar                |william@domain.com

3                     | Ajay                        |                                     |ajay.srs@domain.com

If Ajay logs in then he can able to see all the records based on Reporting_TO_Name, here the Reporting_TO_Name Ajaykumar both belong to ajay.srs@domain.com

 

when ajay logs into power bi service in the profile tab on right corner his name display as Ajay Kumar and email id is ajay.srs@domain.com

I used the roles as 

[Email_address] = USERPRINCIPALNAME() ||
[Reporting_TO_Name] & "@domain.com" = USERPRINCIPALNAME()

 

I want to compare the Reporting to name with the display name once user logins.

 

 

Please Help me to get the solution on this.

Thanks 

 

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@Charu,

In your scenario, create two roles, one using the DAX below. In Power BI Service, add Ajay as member of this role.

1=1


Another using DAX below.

[Email_address] = USERPRINCIPALNAME()



Regards,
Lydia

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

View solution in original post

5 REPLIES 5
v-yuezhe-msft
Employee
Employee

@Charu,

In your scenario, create two roles, one using the DAX below. In Power BI Service, add Ajay as member of this role.

1=1


Another using DAX below.

[Email_address] = USERPRINCIPALNAME()



Regards,
Lydia

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

Hi @v-yuezhe-msft

I'm already doing the way you suggested, I thought there is no other option so I tried the same like you shared .

Thank you so much for your support. Woman Happy

Hi how did you solve the problem even i am facing the same issue kindly share the resolution. i am using direct query.

 

thanks,

Aravindan M

v-yuezhe-msft
Employee
Employee

@Charu,

Create a new column in your table using DAX below.

is manager = IF(Table[Reporting_To_Name]="",1,0)


Create the role using DAX below.

If(MaxX(
Filter(
Table,
Table[Email_address]=Username())
,Table[is manager])=0,
Table[Email_address]=Username(),
1=1
)


Reference:
http://radacad.com/dynamic-row-level-security-with-manager-level-access-in-power-bi

Regards,
Lydia

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

HI @v-yuezhe-msft

I'm getting the following error message as 

Function 'MAXX' is not allowed as part of the row level security expression on DirectQuery models

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.