Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Need Help with DAX for Dynamic RLS to avoid bi-directional relationship

Hi all, 

 

have to implement dynamic RLS on country where one user is allowed to see their own country data wheen user is not manager and if user is manager(IsManager=1)they should see all countries data means no RLS.

 

Please note that I shouldn't use bidrectional relationship in my data model so that role should be applied on country table that should filter FACT table.

 

Employee-Country table looks like below

| UserID | Email Address | Country    | IsManager |
|--------|---------------|------------|-----------|
| 1      | [email protected] | Finland    | 0         |
| 2      | [email protected] | Italy      | 0         |
| 3      | [email protected] | Spain      | 0         |
| 4      | [email protected] | Belgium    | 0         |
| 5      | [email protected] | AllCountry | 1         |
| 6      | [email protected] | AllCountry | 1         |
| 7      | [email protected] | Finland    | 0         |
| 8      | [email protected] | Belgium    | 0         |
| 9      | [email protected] | Finland    | 0          |

Country Table

| Country | CountryID |
|---------|-----------|
| Finland | 1         |
| Belgium | 2         |
| Italy   | 3         |
| Spain   | 4         |

Fact Table

| FactID | Country | Amount |
|--------|---------|--------|
| a      | Finland | 100    |
| b      | Italy   | 200    |
| c      | Spain   | 300    |
| d      | Belgium | 400    |
| e      | Belgium | 200    |
| f      | Italy   | 150    |
| g      | Spain   | 300    |
| h      | Spain   | 390    |
| i      | Belgium | 400    |

Data Model looks like

 

Employee Country and Country is Joined on Country column

Fact table is joined with Country on Country column

I am trying the below DAX in Country table but its not working when user is not manager 

IF(
LOOKUPVALUE('Employee-Country'[IsManager],'Employee-Country'[Email Address],USERPRINCIPALNAME())=1,
TRUE(),
MAX('Employee-Country'[Email Address])= USERPRINCIPALNAME())

 

Any help would be much appreciated

Thank you in advance!

 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Jihwan_Kim  could you please help with DAX whenever you will have time . 
    Thank you

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Will you consider to change the direction of the relationship to "Both" and check again?

     

    Best Regards,

    Jay

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Anonymous for your response, It works fine with bidirectional relationship