Saturday, December 3, 2022

How to implement a Page Level Security in Power BI Report

How to Restrict users to View and Navigate to only Specific Pages in a Power BI Report
Scenario:
Lets suppose we have 2 users, say User1, User2, and a Report with 4 Pages as shown below:

Users:

Report Pages:

Now we wants to restrict the users to View only the specific Pages that are Mapped to them are allowed Navigate and View in the Report, based user login to the Power BI Service. 
We can fulfill this Scenario as explained below.

1) Create a new Page Navigator Table in the Report:
We will use Dax DATATABLE Function to Create a Page Navigator Table, where we map the Users to the Report Pages, and a Navigation Flag, which enable or disables the user to the Specific page allowed View.

PageNavigaor =
DATATABLE("Page Index", INTEGER, "Page Name", STRING, "UserName",
STRING,"UserID", STRING,"Nav Flag", INTEGER,
        {
            {1, "Page View1", "User1", "TPREDDY-PC\Elephant",1},
            {2, "Page View2", "User1", "TPREDDY-PC\Elephant",0},
            {3, "Page View3", "User1", "TPREDDY-PC\Elephant",1},
            {4, "Page View4", "User1", "TPREDDY-PC\Elephant",0},
            {1, "Page View1", "User2", "TPREDDY-PC\Tiger",1},
            {2, "Page View2", "User2", "TPREDDY-PC\Tiger",1}
        })

Result:

Notes:
In the above table, the "User1" is allowed to View 4 Pages but Navigation is allowed only to the Page View1 ; Page View2.
Similarly, the "User2" is allowed to View and Navigate to the Page View1 ; Page View2.
Please note:
We can ignore the "Nav Flag" as it is not needed in general Scenario. However I just wish to explain how things works differently.

2) Define a new Role as "PageSecrity" from Modeling > Manage Roles:
We pass the USERPRINCIPALNAME() as filter on [UserID] field of the PageNavigator table.



3) Create a Page Slicer and a Go Button to Navigate to the Selected Page:
Add a Landing Page in the Report, and add a Slicer based on the PageNavigaor[Page Name] and make it a Horizontal Slicer and enable only the Single Selection.
Next create a Blank Button with Title as "Go" and format as you wish.


4) Next view as the Roles to see the Pages reflecting based on User :
View as User1 : TPREDDY-PC\Elephant : This user is allowed to View 4 Pages in the Slicer to Navigate.

View as User2 TPREDDY-PC\TigerThis user is allowed to View 2 Pages in the Slicer to Navigate.



5) Define the following Measures needed to set the Page Navigation:
Selcted Page = SELECTEDVALUE(PageNavigaor[Page Name])
Navigation Flag = SELECTEDVALUE(PageNavigaor[Nav Flag])

Page to Navigate = IF( PageNavigaor[Navigation Flag]=1,
            SELECTEDVALUE(PageNavigaor[Page Name], BLANK()))

Other Measures for Formatting, ToolTip and Message options.
Dyn Color = IF (PageNavigaor[Navigation Flag]=0, "#DE6A73", "#FFFFFF")

Dyn ToolTip = IF (PageNavigaor[Navigation Flag]=0,
                    "You are not allowed to Go", "Go to the Page to View")

Navigation Msg = IF( PageNavigaor[Navigation Flag]=0,
"Hi User, You are not allowed to Navigate to this Page: "& [Selcted Page],
BLANK())

6) Add the Action as "Page Navigation" to the Go Button.
We can use the "Page to Navigate" measure in the Action as as "Page Navigation" to the Go Button.



7) Add the Message to User if specific Page is not allowed to Navigate.
Lets say, the User1 is allowed to see 'Page View2" in the Slicer but not allowed to Navigate. In this specific Scenario, we can display a Magic Button which display the message to the User1 when clicks on Page View2.

For the GO button tooltip, we can use the measure "Dyn ToolTip", and for the Message Button , we can use the measure "Dyn Color"  in the following sections:
Button > Style > Text > Font Color ;
General >Visual Border > Color

8) Finally, hide all required Pages(except Landing Page), and add a Back Button in each of the Page:

--------------------------------------------------------------------------------------------------------
Thanks, TAMATAM ; Business Intelligence & Analytics Professional
--------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog