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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Anonymous
Not applicable

Row Level Security DAX Expression not working with USERPRINCIPALNAME()

I'm trying to implement a row level security using the below code but it doesn't work as intended.

However, when I replaced USERPRINCIPALNAME() with the actual email address, the RLS filter works. Is there something wrong with my DAX expression which does not allow USERPRINCPALNAME() to work?

Below is the email mapping table. This is a standalone master data and will have a one to many relationship to the main table which requires row level security filtering as per the USERPRINCIPALNAME()

 

1 ACCEPTED SOLUTION
aduguid
Memorable Member
Memorable Member

Try this DAX

[dept] = MAXX(
    FILTER(
        email_mapping, 
        CONTAINSSTRINGEXACT(TRIM(email_mapping[Permissions]), TRIM(USERPRINCIPALNAME()))
    ),
    email_mapping[Dept]
)

View solution in original post

4 REPLIES 4
Joe_Barry
Solution Sage
Solution Sage

Hi @Anonymous 

 

If the Department column has a relationship with the Fact Table Department, then try this.

CONTAINSSTRING(email_mapping[Permissions], USERPRINCIPALNAME())

Joe




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn


Let's connect on LinkedIn


Anonymous
Not applicable

Thanks for the reply. Yes the Department column has a relationship with the Fact Table Department. The DAX Expression you have provided seems no different to mine? 

It is that in that there is no need to define the Department if you have a relationship between both tables.

I am presuming that you are using the Modeling > Manage Roles feature?

Joe_Barry_0-1723108411616.png

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn


Let's connect on LinkedIn


aduguid
Memorable Member
Memorable Member

Try this DAX

[dept] = MAXX(
    FILTER(
        email_mapping, 
        CONTAINSSTRINGEXACT(TRIM(email_mapping[Permissions]), TRIM(USERPRINCIPALNAME()))
    ),
    email_mapping[Dept]
)

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

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.