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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
AAAA[email protected]
BBBB[email protected]
CCCC[email protected],[email protected]
DDDD[email protected],[email protected]

 

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

 

CustomerIDCustomer Nameemail
AAAA[email protected]
BBBB[email protected]
CCCC[email protected]
CCCC[email protected]
DDDD[email protected]
DDDD[email protected]
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 ([email protected] and [email protected]) to have access to Company B and C`s data.

Does it make sense ?

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.