Forum Discussion

powerbiexpert22's avatar
powerbiexpert22
Icon for Impactful Individual rankImpactful Individual
11 months ago
Solved

Restrict Report or Pages in Report based on user persona

can it be possible to provide report or pages access based on information stored in database table like below 

Group NameAccess
DirectorAll reports of all departments
Sales MDAll reports of Sales Department 
Sales Team LeadOnly Summary Page of Sales Report
SalesmanOnly Detail Page of Sales Report

 

  • Cookistador's avatar
    Cookistador
    11 months ago

    Imagine,

    You have a talbe access like this one:

     

    Then, you just have to create measure like: 

    CheckPageAccess =
    VAR CurrentUser = USERPRINCIPALNAME()
    VAR SelectedPage = AccessiblePage (one value from your table)
    VAR HasAccess =
    CALCULATE (
    COUNTROWS ( 'SecurityTable' ),
    'SecurityTable'[UserEmail] = CurrentUser,
    'SecurityTable'[AccessiblePage] = SelectedPage
    )
    RETURN
    IF ( HasAccess > 0,SelectedPage, Blank())

     

    If you use this approche, you have to be sure that people do not have access to download the report, or they could unhidde your page

8 Replies

  • Hello powerbiexpert22 

     

    There are two ways to achieve that:

    -The first and easiest one, would be to create an app with the right audience

     

    If this solution doesn't fit for you, I had a similar request for a customer, I create a button for  each pages, and then the access of the button was set up with the command USERPRINCIPALNAME() and a dataflow which extrced the user from all groups and stored them in a secured table

     

    But definitely, if I was you, I would have a look on Power BI app 

    https://learn.microsoft.com/en-us/power-bi/collaborate-share/service-create-distribute-apps

    • KarinSzilagyi's avatar
      KarinSzilagyi
      Icon for Super User rankSuper User

      Cookistador I came for the same solution, but rather than using a dataflow and userprincipalname() I would recommend a table with the roles and apply RLS and assign either the individual users or whole AD-groups to those roles.

    • powerbiexpert22's avatar
      powerbiexpert22
      Icon for Impactful Individual rankImpactful Individual

      Hi Cookistador ,

      can you explain below the second option or provide any documentation or video for this option

       

       

       

      • Cookistador's avatar
        Cookistador
        Icon for Super User rankSuper User

        Imagine,

        You have a talbe access like this one:

         

        Then, you just have to create measure like: 

        CheckPageAccess =
        VAR CurrentUser = USERPRINCIPALNAME()
        VAR SelectedPage = AccessiblePage (one value from your table)
        VAR HasAccess =
        CALCULATE (
        COUNTROWS ( 'SecurityTable' ),
        'SecurityTable'[UserEmail] = CurrentUser,
        'SecurityTable'[AccessiblePage] = SelectedPage
        )
        RETURN
        IF ( HasAccess > 0,SelectedPage, Blank())

         

        If you use this approche, you have to be sure that people do not have access to download the report, or they could unhidde your page

    • Cookistador's avatar
      Cookistador
      Icon for Super User rankSuper User

      What kind of information do you have ?

      The name/email adress and to what they can access? If yes, you just need to import the table and use this table to set up the rules?

       

      If it is not the case, can you share a dummy sample of what the data looks like ?

      • v-sgandrathi's avatar
        v-sgandrathi
        Icon for Community Support rankCommunity Support

        Hi powerbiexpert22,

         

        Thank you for the update. To give a clear example of how to link database-stored access details to report or page visibility, could you share a small dummy sample of your access table? as Cookistador mentioned. For example, 4–5 rows with the exact column names (such as UserEmail, Role, Department, PageName, AccessLevel, etc.) and some sample values.

         

        Thank you.