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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
hideakisuzuki01
Helper II
Helper II

Dynamic RLS with multiple USERPRINCIPALNAME()

Hi

I am trying to implement dynamic RLS but having trouble and it would be great if I could some help.

I have the below two tables and I have the below formula 

 

[email] = USERPRINCIPALNAME()

 

It works fine for the first two customerIDs (A and B) but it does not work for Customer IDs C and D.

It would work if I create multiple rows for C and D but that would make the table relationship many to many and produces wrong data.

How could I implement dynamic RLS in this situation ?

 

IDAmountCustomerID
1100A
2200A
3300B
4400B
5500B
6600C
7700C
8800D
9900D
101000D
CustomerIDCustomer Nameemail
AAAA111@xxxxxx.com
BBBB222@xxxxx.com
CCCC222@xxxxx.com,333@xxxxx.com
DDDD333@xxxxx.com,444@xxxxx.com

 

Below table would work but the data would be wrong since it would be many to many relationship.

 

CustomerIDCustomer Nameemail
AAAA111@xxxxxx.com
BBBB222@xxxxx.com
CCCC222@xxxxx.com
CCCC333@xxxxx.com
DDDD333@xxxxx.com
DDDD444@xxxxx.com
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @hideakisuzuki01 

I build two tables like yours to have a test.

Data Table:

1.png

User Table (It has been transformed in Power Query editor by Split.):

2.png

Build a many to many relationship between CustomerID columns in two tables.

Then Add two Dax expression in Mange roles.

In Data table:

[CustomerID] = 
CALCULATE (
    MAX(Data[CustomerID]),
    FILTER (
        User,
        User[email] = USERPRINCIPALNAME()
            && User[CustomerID] = Data[CustomerID]
    )
)

In User table:

[email] = USERPRINCIPALNAME()

Let's use view as to see the result.

3.png

You can download the pbix file from this link: Dynamic RLS with multiple USERPRINCIPALNAME()

 

Best Regards,

Rico Zhou

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @hideakisuzuki01 

I build two tables like yours to have a test.

Data Table:

1.png

User Table (It has been transformed in Power Query editor by Split.):

2.png

Build a many to many relationship between CustomerID columns in two tables.

Then Add two Dax expression in Mange roles.

In Data table:

[CustomerID] = 
CALCULATE (
    MAX(Data[CustomerID]),
    FILTER (
        User,
        User[email] = USERPRINCIPALNAME()
            && User[CustomerID] = Data[CustomerID]
    )
)

In User table:

[email] = USERPRINCIPALNAME()

Let's use view as to see the result.

3.png

You can download the pbix file from this link: Dynamic RLS with multiple USERPRINCIPALNAME()

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

amitchandak
Super User
Super User

@hideakisuzuki01 , c is having same email ID as B ? Same for D same email ID as C.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Yes, B and C has the same email, because I want both users (222@xxxxx.com and 333@xxxxx.com) to have access to Company B and C`s data.

Does it make sense ?

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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