Row Level Security (RLS) and Object Level Security(OLS) in Power BI

Sapana Taneja
Microsoft Power BI
Published in
5 min readJun 26, 2024

This article will dive into more detail about RLS and OLS how to use and when to use each.

Security in Power BI

RLS(Row Level Security) name tells us it is used to secure the row’s data.

OLS(Object Level Security) secures the column or table.

RLS is two type

  1. Static RLS
  2. Dynamic RLS

For illustration purposes, I will use a small example of a region-wise sale.

Problem Statement: Display the sales data of each region such that the sales figures are shown for their respective regions

we will solve it by using static RLS.

Region-wise Sales

for that, we will manage the role in the modeling tab on the home ribbon.

  1. Go to the modeling tab
  2. Click on manage roles.
  3. In the manage security roles window create roles for respective regions by adding new roles.
  4. By selecting each role add a filter for a particular region as shown in the below image and save the page.
Manage Role

5. to view whether the role is working properly we can click on the view roles tab

Now publish it to your workspace in Power BI Service and manage access to determine who can view the report.

And here’s an important point to note: Only viewer access should be given to the user to apply RLS.

Manage Access
Viewer Role assigned in manage access

After that click on three dotes of the semantic model of the report and go to Security

Security on Semantic Model

Assign the RLS to the respective region member and click on the save button

Assigned RLS to members

Now, when a member assigned to view the central region’s data opens the report, they can only see the data of their respective region.

Limitation: In the above example, we only have four regions to assign RLS. However, if we need to apply RLS to states and cities, manually entering roles for each city becomes cumbersome. In such cases, Dynamic RLS can be used.

Dynamic RLS

For Dynamic RLS we require a user access table containing the user mail ID and respective state they can access usually, we will get this data in Excel format but in this example, we will directly enter the data in a table.

User_access table

In the modeling tab, we have to make a relationship between two tables

Relationship between tables

Similar to Static RLS now we have to manage the role but the difference is here we will use the “USERPRINCIPNCIPALNAME” DAX function to the role and save it.

Manage Role- USERPRINCIPNCIPALNAME

and also create a measure to check the user value

Measure for user

when we drop that measure in the report it will display our system name on the desktop but when we publish it in the Power BI service and repeat the same steps that we have done in static RLS such as managing access and assigning RLS in the security tab of semantic model it will display the user-id/mail-id of the logged in user.

Report with User name

OLS (Object Level Security )

As discussed earlier, RLS is used to secure data by Rows, while OLS is used for Columns and Tables.

We can’t directly use OLS in Power BI. To achieve this, we need to use the external tool/third-party tool Tabular Editor. you can install it https://tabularediat tor.com/ and connect it with Power BI.

Problem Statement: In a table containing State, Sales, Profit, and Qty, the requirement is that when we apply OLS (Object-Level Security) to the Profit column or the entire table, the data should not be visible to the user.

Sales data

Similar to RLS, we also need to manage the role in Power BI desktop and Power BI services.

Manage OLS Role

In Tabular Editor if we select the order table, set OLS as None and save it. it means that the user has not been given access to see the complete table of data

OLS on Complete table

And when the user tries to view the data, they will not see any records or will encounter restricted access

The user is not able to see the complete Order table

But now we want to apply OLS on the Profit column in the order table

Now you can see that the user can access the table only which does not have a profit column.

Conclusion

As per our project requirements, we can apply security on rows, columns, and tables using RLS and OLS

I hope you found this article helpful! If you did, please consider clapping to show your support. If you have any questions or thoughts to share, feel free to leave a comment below. I’d love to hear your feedback!

Happy Learning…!!!

Don’t forget to subscribe to

👉 Power BI Publication

👉 Power BI Newsletter

and join our Power BI community

👉 Power BI Masterclass

--

--

Sapana Taneja
Microsoft Power BI

I'm passionate about unveiling data stories. I have keen interest in EXCEL, Python, SQL, Power BI, Tableau. Join me in exploring the captivating world of data!