Loading...

Implementing Row-Level Security (RLS) in Power BI

Implementing Row-Level Security (RLS) in Power BI
Implementing Row-Level Security (RLS) in Power BI

Introduction:

Row-Level Security (RLS) in Power BI allows you to restrict data access for specific users based on defined roles. In this blog, we will demonstrate how to create and implement an RLS role named "country_filter" to restrict sales data visibility based on user countries. This is achieved using the DAX function: [Username] = USERPRINCIPALNAME()

Step 1: Setting Up Your Data Model

Before implementing RLS, ensure your Power BI model has the following:
Sales Table - Contains sales data with a Country column.
User Table - Contains Username and Country.
Relationship - Establish a relationship between the Country column in both tables (many-to-one relationship).

Implementing Row-Level Security (RLS) in Power BI

Step 2: Create a Security Role

1. Navigate to the "Model" View:

In Power BI Desktop, go to the "Model" view to work on roles and relationships.

2. Access the Security Settings: 

On the "Modeling" tab, select Manage Roles.

3. Create a New Role:

Click Create and name the role as country_filter. Select the User Table from the list of tables.

4. Define the DAX Expression:

In the "Table Filter DAX Expression" box, write the following expression:

[Username] = USERPRINCIPALNAME()

5. Save the Role:

Click Save to finalize the role.

Implementing Row-Level Security (RLS) in Power BI

Step 3: Test the Role in Power BI Desktop

1. Simulate User Access:

On the "Modeling" tab, select View As Roles.

2. Choose the country_filter role.

Enter a username (email) to test if the filtering works correctly.

3. Validate Results:

Check if only the sales data for the corresponding country is displayed.

Implementing Row-Level Security (RLS) in Power BI

In our project, we have created five email ids as username and 5 different nationalities, i am using [email protected] to filter the data by the country United States of America as shown below,

Implementing Row-Level Security (RLS) in Power BI

When we Test the Role in Power BI Desktop, only the sales data for the corresponding country aginst the username is displayed as below,

Implementing Row-Level Security (RLS) in Power BI

Step 4: Publish to Power BI Service

1. Publish the Report:

Save and publish your Power BI file to the Power BI Service.

2. Assign Users to the Role:

Go to your dataset in Power BI Service.

Click on the ellipsis (...) > Security.

Select the country_filter role and add email addresses of users who should have this access.

Implementing Row-Level Security (RLS) in Power BI

Step 5: Execute and Test RLS in Power BI Service

1. Verify Access:

Log in as one of the assigned users.

Open the report in Power BI Service and confirm that only the relevant country’s data is visible.

2. Iterate and Fine-Tune:

Make necessary adjustments to the data model or DAX expression based on feedback.

Implementing Row-Level Security (RLS) in Power BI

Conclusion

Implementing RLS with dynamic user filtering enhances the security and usability of Power BI reports. By following the steps outlined in this guide, you can easily control data access and provide a tailored experience for users.

Let us know how RLS improved your report's security or reach out with any questions in the comments! 🌟

Published on:

Learn more
D365 Snippets
D365 Snippets

Share post:

Related posts

Optimising DAX: VertiPaq Encoding Techniques

VertiPaq fits millions of rows in memory by compressing columns. Learn how value, hash and run-length encoding work, and what they mean for mo...

1 day ago

Building in the Agentic Era with Power BI and Fabric

Microsoft Build 2026 marks a major shift in how developers build data experiences with AI agents. Today we're announcing two capabilities that...

2 days ago

Power BI at Microsoft Build 2026: The Agentic Era of analytics

Microsoft Build 2026 brings the next generation of intelligent analytics to Power BI—where agents do the building, apps deliver insights ...

2 days ago

DAX User-Defined Functions (Generally Available)

DAX user-defined functions are now production-ready based on community feedback and internal validation. Their adoption during preview shows t...

2 days ago

No Code Power BI: How to Use Claude and the Power BI Modeling MCP Server

What if you could build a complete Power BI semantic model — date table, time intelligence measures, relationships and all — without touching ...

6 days ago

Power Query, Dataflows, and What’s Next — A Conversation with Miguel Escobar | Fabric Insider Ep. 3

Power Query is one of those tools that has been close to my heart for a very long time. I wrote a full book on it, I have trained thousands of...

6 days ago

Microsoft Cans Power BI App for Microsoft 365 Usage

Microsoft has announced that the Microsoft 365 Usage Analytics Power BI app will retire on August 1, 2026. The alternative is the usage report...

7 days ago

Microsoft 365 Usage Analytics Power BI template app will be retired

The Microsoft 365 Usage Analytics Power BI template app will be retired, with new downloads ending June 1, 2026, and support ending August 1, ...

8 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy