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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Changing active relationship based on column value for role level security

Hi all!

 

Below I have two tables, with one active relationship (teamid-teamid) and one inactive relationship (personnellnumber-reportsto).

 

relationship2.PNG

Is it possible to make a DAX that says (pseudo): 

If teamlead = "Yes" then USERELATIONSHIP(table1[personnellnumber], table2[reportsto]),

otherwise use existing relationship

 

And on both, [email] = USERPRINCIPALNAME() should be applied. 

 

I'm can't determine if this is an if, switch or calculate solution..

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

If amitchandak's suggestion doesn't lead you to a solution, please have a look at my suggestion.

Based on my understanding, you have employees part of whom are leaders.

 

1.

If Table1 contains all employees including leaders and common employees,

Table2 contains the scoresor other information for all employees in Table1.

If so, please refer to the article:

Dynamic Row Level Security with Manager Level Access in Power BI

 

2.

If Table1 contains parts of employees including leaders and common employees,

Table2 contains parts of employees including only common employees, no leaders.

Your requirement is to show information for specific member:

eg,

lead of team 1 will see all information of this team,

employee 2 will only see his own information.

 

If so, please refer to my pbix:

Steps:

(1)

In edit queries, in Table2(employee table), append table1 to table 2,

at the same time, make some transformations for table 2

Next, filter Table1(leader table) to contain rows isteamlead=true/1/yes

Capture5.JPG

 

Capture6.JPG

Close&&apply

 

(2)

Create relationship

Capture7.JPG

 

(3)

manage role

Capture8.JPG

Finally

Capture9.JPG

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Is this problem sloved? 
If it is sloved, could you kindly accept it as a solution to close this case?
If not, please let me know.
 
Best Regards
Maggie
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

If amitchandak's suggestion doesn't lead you to a solution, please have a look at my suggestion.

Based on my understanding, you have employees part of whom are leaders.

 

1.

If Table1 contains all employees including leaders and common employees,

Table2 contains the scoresor other information for all employees in Table1.

If so, please refer to the article:

Dynamic Row Level Security with Manager Level Access in Power BI

 

2.

If Table1 contains parts of employees including leaders and common employees,

Table2 contains parts of employees including only common employees, no leaders.

Your requirement is to show information for specific member:

eg,

lead of team 1 will see all information of this team,

employee 2 will only see his own information.

 

If so, please refer to my pbix:

Steps:

(1)

In edit queries, in Table2(employee table), append table1 to table 2,

at the same time, make some transformations for table 2

Next, filter Table1(leader table) to contain rows isteamlead=true/1/yes

Capture5.JPG

 

Capture6.JPG

Close&&apply

 

(2)

Create relationship

Capture7.JPG

 

(3)

manage role

Capture8.JPG

Finally

Capture9.JPG

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

Try something like this

Sales 9 = 
VAR Column1=
    SELECTEDVALUE ( dim[DimColumn1])
VAR Column2 =
    SELECTEDVALUE ( Sales[Second])
var Column3 =SUMMARIZE(Sales,Sales[Column1])
var Column4 =SUMMARIZE(Sales,Sales[Column2])
RETURN
   if(ISBLANK(Column1), CALCULATE( SUM (Sales[Sales]),
        dim[DimColumn1] in Column3  ,USERELATIONSHIP(dim[DimColumn1],Sales[First])

    ),CALCULATE( SUM (Sales[Sales]),
        dim[DimColumn1] in Column4  ,USERELATIONSHIP(dim[DimColumn1],Sales[Second])

    ))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Sorry, could you clarify? 

Is this in Manage Roles, or are you making a measure/column here? 

Measure has been created
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors