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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

RLS with related condition using two tables in same role

Hello,

 

I am trying to write a dax for a single role and I want to use fields to create multiple situations using two tables within the same role and same table. I cannot create multiple roles for this condition.  Sample data:

TABLE A

IdA          Colx         Coly
1               D             US
1               I             US
2               D             CA
2               I            IN

 

 

TABLE B

IdB      role      Inter      Dom

1         true      true       false

2         true      false      true

3         true      false      false

4         true

 

Now I want to write one dax such that:

 

( ([RoleS] = TRUE() && Dom = False() || Dom = BLANK()) && ([Inter] = False() || [Inter] = BLANK()))

AND Colx = "D" )

 

OR

 

(

[RoleS] = TRUE()

 

&&

 

(
[Dom] = TRUE() || [Inter] = TRUE()
) && NOT(ISBLANK([Dom])) AND  

Colx = "D" || (Colx = "I" && Coly = "US"

)

 

Table A have many to one relationship with Table B. I need to write one common DAX for both of these situations, or if a third situation is in addition where I want any value for colx or any value for colY.

 

Please help! thanks

1 REPLY 1
lbendlin
Super User
Super User

Sounds like you need to apply your RLS rules to Table A and you need to pull in all three columns from Table B via Power Query lookups. Are you really sure you want to do that? Normal RLS is applied to dimension tables (Table B) and then propagated down via the data model.

 

This part 

 

 ([RoleS] = TRUE() && Dom = False() || Dom = BLANK())

 

most likely does not do what you expect.  I think you wanted to write

 

 [RoleS] = TRUE() && (Dom = False() || Dom = BLANK())

 

See pbix attached

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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