Forum Discussion

powerbidev123's avatar
powerbidev123
Solution Sage
1 year ago
Solved

RLS setup for continent users group

Hi .  I have a dataset that consists of user emails and the continent they belong to. Columns: email, region   And another dataset that maps the region to each country   How can i setup RLS for...
  • Jonvoge's avatar
    1 year ago

    Hi powerbidev123

     

    The most effective way would be to use dynamic RLS, using the DAX formula USERPRINCIPALNAME() to retrieve the user email of the current user, and use it in your RLS rule. This allows you to define a single RLS rule, as opposed to creating rules for each country/continent, and adding all relevant users to each role.

     

    Your solution requires the following steps:

    1. Create a new RLS role, call it eg 'DynamicRLS', and add the DAX expression for your User/Continent Table: email = USERPRINCIPALNAME()

    2. Ensure that the User/Countinent table filters the rest of the model through a relationship. 1:many.

    3. Publish the semantic model to the service

    4. In the Security settings for the semantic model, add all of your users (ideally through an AD group) to the role that you created.

     

    And that's it!

    _____________________________________________________
    I hope my comment was helpful.
    If your question was answered, please mark your post as 'Solved' and consider giving me a 'Thumbs Up'.
    Find me on LinkedIn, Sessionize, or my blog Downhill Data

     

  • v-karpurapud's avatar
    1 year ago

    Hi powerbidev123 

    Welcome to the Microsoft Fabric Community Forum.


    To configure Row-Level Security (RLS) for a continent-based user group, follow the dynamic RLS approach as highlighted by Jonvoge . Use the DAX function USERPRINCIPALNAME to filter the UserRegion table based on the logged-in user's email. Ensure the data model has proper relationships in place: UserRegion[region] should be linked to RegionCountry[region], which in turn should be linked to FactTable[country]. These relationships enable the filter context to flow seamlessly from the user to the relevant countries they are allowed to see. Once the role is created with this dynamic filter, test the configuration using the "View as Role" feature in Power BI Desktop and the "Test as Role" option in Power BI Service to confirm that each user only sees the appropriate country-level data based on their assigned region.

    I hope this information is helpful.

    If this response addresses your query, please consider marking it as the Accepted Solution.

    Thank you for being part of Fabric Community Forum.

    Regards,
    Karpurapu D,
    Microsoft Fabric Community Support Team.