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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
wow921
New Member

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
Super User
Super User

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
Super User
Super User

Hi @wow921 

 

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


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
Super User
Super User

Try this DAX

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

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

October NL Carousel

Fabric Community Update - October 2024

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