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.

 

 

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

 

 

 

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?

 

 

 

[dept] = MAXX(FILTER(email_mapping, CONTAINSSTRING(email_mapping[Permissions], "234@abc.com")),email_mapping[Dept])

 

 

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()

 

DeptPermissions
finance123@abc.com; 234@abc.com; 345@abc.com
IT3245@abc.com; 4567@abc.com
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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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