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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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

    ))
Anonymous
Not applicable

Sorry, could you clarify? 

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

Measure has been created

Helpful resources

Announcements
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.