Forum Discussion

Senthil_Kumar's avatar
Senthil_Kumar
Frequent Visitor
4 years ago

RLS or Modeling for user role based on dual condition

Hello Everyone,

I have 2 data sets, User and dealers under them & another one is Opportunities data where I have leads data from buyers from different countries. Both the tables are modeled based on dealer id.

The user in above data have different roles, my requirement now is for just role 3 user id's, they should see only Opportunities of their respective coutry and for rest of the role they can see all countries data. But with my current modeling they are able to see all data based on dealer id  modeling.

Example:  user id 3  has access to OpportunityId 4 & 5 but he should see only OpportunityId 5 since his country is US.

Similary User id 5 should see only OpportunityId 6 & not 8.

But for a super user like say User id 1 he should see both OpportunityId 1 & 2 which is of CA and US.

Could any one help me with how to acheive this based on current modeling and role based user's country as well.

3 Replies

  • Sounds like you need a composite key "Dealer-Country"  in both tables.

  • v-kkf-msft's avatar
    v-kkf-msft
    Icon for Community Support rankCommunity Support

    Hi Senthil_Kumar ,

     

    First create a relationship between [Dealer id].

     

     

    Then create the following filters for role 3.

     

    [User role] = 3 
    
    CALCULATE (
        COUNTROWS ( Opportunities ),
        INTERSECT (
            SUMMARIZE (
                Opportunities,
                Opportunities[Dealer id],
                Opportunities[Opportunity_Country]
            ),
            SUMMARIZE (
                FILTER ( User_Dealer, User_Dealer[User role] = 3 ),
                User_Dealer[Dealer id],
                User_Dealer[User Country]
            )
        )
    ) > 0

     

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

  • Senthil_Kumar's avatar
    Senthil_Kumar
    Frequent Visitor

    v-kkf-msft , In my case RLS is based on User id, each user has set of dealers under them and also each user has a role defined to them. Above case will not fit perfectly to my scenario and also you have used static role number, what if user other than role 3 will login? It has to be completely dynamic based on avaiable role and user id.