Saturday, February 10, 2018

How to create Row Level Security to restrict Users from specific Data Views of the Power BI Report

How to Implement Row Level Security (RLS) in Power BI to restrict Users from specific Data Views of the Report
Row Level Security is a Security feature in Power BI Reports, that restricts the users to view the data in the report based on the User Roles assigned to their particular User Group.
Scenario:
If you want to allow the end users to view only the Sales in their specific Sales Region data, instead of viewing all regions, we can restrict them by defining the 
User Roles and assigning the Users to that User Group .
Example :
Suppose we have a Power BI Report , where we have the data of various Sales Regions like North America, Africa, Europe.


Now we will define the user roles on top of this report, based on the Sales_Region column as follows..

1) Go to Report tab Modeling  and then select the User Roles


2) Next Define the Team Name in Manage Roles and apply the required Filters on required Tables.
Here I have created to two Teams with below Filters on the Table vSalesByRegion :
Asia Team :
[Region_Name] = "Asia"

WorldWide_Team :
OR ([Region_Name]="Europe",[Region_Name]="North America")


Note :
We can implement the Dynamic Row Level Security (RLS), by mapping the UserId (if exists in the Model) to the USERNAME()USERPRINCIPALNAME() Functions of the Power BI.

3) Next validate the Roles by viewing the Report by defined Team Roles
View as Roles : Asia_Team:

Now the Report will shows only the Data for Asia Region as follows..
View as Roles : WorldWide_Team:
Now the Report will shows Data for Europe and North America Regions as follows..
4) Finally Publish the Report to Power BI Service and add the Users to the User Role Teams
Once we Publish Report to Power BI Service , we have to add the Users to the specific User Role Teams based on their Sales Region and requirement as follows..
In Power BI Service we will see the following things in the Work Space :
a) Dashboards
b) Reports
c) Datasets

Go to Datasets , then select our report Dataset on which we want apply the Row Level Security, as follows..
Click on the ...3dot icon next to the Dataset and then click on SECURITY option.
Next select the User Role Team ( Eg : Asia_Team) to add MEMBERS.
Next add the People or groups who belongs to this role, by specifying their email address.
Finally click Add.
Now People or groups who belongs to this role, will have access to view the data as per that Role definition we defined in Power BI Desktop Report.

Creating a Schedule Refresh Plan :
We can schedule the Power BI Reports to refresh automatically from Power BI Service
  • In the Work Space > Data sets , select your Report dataset and then click on ..3dot icon and then click on Schedule Refresh option.
  • On the Scheduled refresh page, select New scheduled refresh plan. 
  • On the New Scheduled Refresh Plan page, enter a description and set a schedule for when you want your data model to be refreshed. 
-------------------------------------------------------------------------------------------------------- 
Thanks, TAMATAM ; Business Intelligence & Analytics Professional 
--------------------------------------------------------------------------------------------------------

How to create and use Dynamic Query Parameters in Power BI Report

Creating and using Dynamic Query Parameters as a Filters in Power BI Report
Scenario:
If you want to allow the end users to Filter and view the Sales in their specific Sales Region data, instead of displaying all regions, we can do it by creating dynamic Parameter in the Report.
We can create a dynamic Query Parameter as follows..
Example :
Suppose we have a Power BI Report , where we have the data of various Sales Regions like North America, Africa, Europe.


 Now we will create a Dynamic Query Parameter based on the Sales_Region of the Query.
1) Go to Edit Queries

2) Create a Query List from Region_Name Column for using in Parameter
From Query Editor > Select column Region_Name from base Table and then R-click and choose the option as Add as new Query


Next Remove the Duplicates from the List, and rename the List


Now a unique List (DistRegion) has been ready to use in Parameter


3) Create a Dynamic Query Parameter using the above List
Go to Home > Manage Parameters > New Parameter


Next create a Parameter and select the suggested values from Query
Now the Parameter appears as follows


4) Apply Filter to the base Table using Parameter
Select the Column Region_Name then got Text Filters > Equals..


Next pass the Parameter as a value


Now the Parameter with the default value "Europe" has been applied to the Report. Please note that this Parameter value will apply dynamically based on user input.


Now Save, Close & Apply the Query Editor Window.

5) Save the Report as Template and Share that Template to the End Users
Once we created and apply the Dynamic Query Parameter, Save as the Report as Power BI Template, which we will share to the end users. This will prompt the users to Select their Sales Region to Load the Report.


Now, when a User opens the Template it will ask to select their Sales Region to View the Report 

Now if we select a Sales Region as Asia, the we will see only the "Asia" Region data as follows..

Important Notes:
Here user can choose and view any Region Data with no Restriction.This will NOT provide a Row Level Security.

If you want to Restrict the users to view only a specific Region data, we should Create and Define the Roles in Power BI Desktop then assign the People to those Roles in Power BI Service.We can also setup the Schedule Refresh in Power BI Service.


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

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