Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

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

 

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

  • 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

     

    Close&&apply

     

    (2)

    Create relationship

     

    (3)

    manage role

    Finally

    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.

5 Replies

  • 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's avatar
      Anonymous
      Not applicable

      Sorry, could you clarify? 

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

  • v-juanli-msft's avatar
    v-juanli-msft
    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

     

    Close&&apply

     

    (2)

    Create relationship

     

    (3)

    manage role

    Finally

    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.

  • v-juanli-msft's avatar
    v-juanli-msft
    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