Forum Discussion

aaedla's avatar
aaedla
Regular Visitor
2 years ago

How to configure security?

Hi,

I have created power bi report from SQL Table A data( Which has Category Column) and published to workspace and provided accesss to users. Now everybody can access the report and see the entire data.

 

Now I am trying to create security based on members table B.

 

Members table has following columns.

UserEmail

User Name

IsUserAdmin(True/False)

CategoryLeader

 

If logged in user is admin then that user should be able to access all the data but if logged in user is Category A leader then the user should be able to see only Catagory A data.

 

I have created roles and configured filters under modeling in power bi and when I select the view as selected role data is getting filtered but I want to make it dynamic based on logged in user category in members table.

 

How to configure this security? Any ideas would be greatly appreciated.

 

3 Replies

  • To configure dynamic row-level security (RLS) based on the logged-in user and their category in the Members table, follow these steps:

    Steps to Implement Dynamic Row-Level Security:

    1. Ensure the Data Model is Set Up Correctly:

      • Table A: Your main data table with the Category column.
      • Table B (Members): The table with user information (UserEmail, IsUserAdmin, CategoryLeader).

      Ensure that Table A is related to Table B through the Category column (i.e., Table A[Category] should be related to Table B[CategoryLeader]).

    2. Create Roles and Filters in Power BI:

      • Open Power BI Desktop.
      • Go to the "Modeling" tab and select "Manage Roles."
      • Create a role for regular users and admins.
    3. Filter by Logged-in User: For the role that filters data based on the user's category, you'll want to apply a DAX filter that dynamically checks the logged-in user’s email and their category in the Members table.

      • Non-Admin Role: Use the DAX expression in the role to filter based on the logged-in user's email and category:

        [Category] = LOOKUPVALUE('Members'[CategoryLeader], 'Members'[UserEmail], USERPRINCIPALNAME())

        This will filter Table A to show only the category that corresponds to the logged-in user's email.

      • Admin Role: For the admin role, you can use a DAX expression that checks if the user is an admin:

        'Members'[IsUserAdmin] = TRUE() || [Category] = LOOKUPVALUE('Members'[CategoryLeader], 'Members'[UserEmail], USERPRINCIPALNAME())

        This will allow admins to see all the data, while non-admins will only see data for their category.

    4. Testing the Roles:

      • After creating these roles, use the "View As" feature to simulate different users' perspectives to ensure the filters work correctly.
    5. Publish and Assign Security:

      • Once the report is ready, publish it to the Power BI Service.
      • In the Power BI Service, go to the dataset settings, and under "Security," assign users to the roles you created.

    This setup will dynamically filter data based on the logged-in user's email, ensuring that admins can view all data, while non-admins are restricted to the categories they lead.

    • aaedla's avatar
      aaedla
      Regular Visitor

      Shravan133 Thank you for your instructions. Everything works as expcted but Step 5 is not working and data is not filtering. 

  • so its working in power bi desktop but not on power bi service? try clearing cache of the report and the browser and publish again.