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
Anonymous
Not applicable

Help with logic on row level security

Please can someone help with a row level security query. 

I have the following tables

EntityA

User

PaulSmith@A.com

JohnSmith@A.com

CarlSmith@A.com

 

EntityB

Name

Icon

A

Z

B

Z

C

X

D

X

F

C

ZA

C

 

I need to create a DAX formula to allow row level security for the following logic

If a user is not in Entity A table then the user should be restricted to see only records where Icon <> C.  If the user is in Entity A then they will have access to all records in Entity B

.

1 ACCEPTED SOLUTION

@Anonymous 

Ah, yes.  Looks like it's the wrong way round.

VAR _User = USERPRINCIPALNAME()
RETURN
	(_User IN EntityA )
	|| ((NOT _User IN EntityA) && EntityB[Icon] <> "C")

PaulOlding_3-1662466448668.png

 

.. here's the results

PaulOlding_4-1662466489414.pngPaulOlding_5-1662466519651.png

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks Paul.

 

Not sure if the above logic will work.  I need to add the filter to the Entity B table in the Mangage Roles section.

PaulOlding
Solution Sage
Solution Sage

Hi @Anonymous 

You could use this in the RLS filter expression for EntityB

VAR _User = USERPRINCIPALNAME()
RETURN
	(_User IN EntityA && EntityB[Icon] <> "C")
	|| (NOT _User IN EntityA)

Be aware that USERPRINCIPALNAME() can give you a different result in Desktop that it does in PBI Service.

Anonymous
Not applicable

I'm receiving the following error:

 

The number of arguments is invalid.  Function CONTAINSROW must have a value for each column in the table expression.

 

Is it because the User field is not specified in Entity A?

@Anonymous 

Ah, yes.  Looks like it's the wrong way round.

VAR _User = USERPRINCIPALNAME()
RETURN
	(_User IN EntityA )
	|| ((NOT _User IN EntityA) && EntityB[Icon] <> "C")

PaulOlding_3-1662466448668.png

 

.. here's the results

PaulOlding_4-1662466489414.pngPaulOlding_5-1662466519651.png

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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