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).
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.
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.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,
When we Test the Role in Power BI Desktop, only the sales data for the corresponding country aginst the username is displayed as below,
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.
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.
Conclusion
Published on:
Learn moreRelated posts
Power Pages – Support for Power BI Embed Token v2 for Power Pages
We are announcing the ability to utilize Power BI Embed Token v2 for Power Pages. This feature will reach general availability on May 30, 2026...
Predicting the Future: Using Power BI to Identify Your Most Profitable Agencies
In the 2026 federal landscape, "growth" is no longer a broad target—it’s a surgical strike. If your executive team is still making "bid/no-bid...
Custom FetchXML Aggregation in Power Pages — Build a KPI Dashboard Without Power BI
Overview Power BI is a great tool — but it requires additional licensing, an embed configuration, and adds complexity to your portal architect...
Power BI Update - April 2026
Power BI Integration with GITHUB
While Azure DevOps is usually the easiest choice for Microsoft users, connecting Power BI to GitHub is becoming a must-have skill for anyone u...
Power BI April 2026 Feature Summary
Welcome to the April Power BI update! Power BI’s April 2026 update is here, bringing continued improvements across Copilot and AI, reporting, ...
How I Built a Full Power BI Semantic Model in Minutes Using Agentic AI and GitHub Copilot
In this second part of my blog series, I will show you how I edited the required files and then created my semantic model by using the Agentic...
A whirlwind tour on User-context-aware calculated columns in Power BI!
Bye, bye translation headaches! With the new User-context-aware calculated columns, we can tackle certain challenges more convenient than ever...
%20in%20Power%20BI.png)






