By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
(Static & Dynamic RLS for Production & Certification)
Row-Level Security (RLS) in Power BI restricts data access at the row level based on user roles. Think of it like a bouncer at a nightclub: instead of giving everyone a VIP pass (full dataset access), you check IDs (user roles) and only let them into their assigned section (rows they’re allowed to see).
USERNAME()
USERPRINCIPALNAME()
Real-World Scenario:You’re a Power BI engineer at a retail chain. The CEO wants a single "Sales Dashboard" for all store managers, but each manager should only see their store’s data. Without RLS, you’d have to: - Create 200+ separate reports (maintenance nightmare).- Risk managers exporting and sharing data they shouldn’t see.With RLS, you define one role (e.g., StoreManager) and filter rows dynamically based on the user’s email or AD group.
StoreManager
Region = "West"
Region = USERNAME()
Sales_East
HR_Manager
[Region] = LOOKUPVALUE(...)
[email protected]
UserEmail → Region
Region
StoreID
Goal: Restrict data so users in the Sales_East role only see rows where Region = "East".
Region = "East"
Example dataset: | OrderID | Region | Sales | |---------|--------|-------| | 1 | East | 100 | | 2 | West | 200 | | 3 | East | 150 |
Go to "Modeling" → "Manage Roles".
Click Create and name the role Sales_East.
Define the filter:
Orders
dax [Region] = "East"
Click Save.
Test the role:
Verify only East rows appear.
East
Publish to Power BI Service:
✅ Verification:- Log in as a user assigned to Sales_East—they should only see East data.
Goal: Restrict data so users only see rows for their assigned StoreID (e.g., [email protected] can only see StoreID = 1).
StoreID = 1
Example: | UserEmail | StoreID | |--------------------|---------| | [email protected] | 1 | | [email protected] | 2 |
Load the security table into Power BI:
Name it UserSecurity.
UserSecurity
Create a relationship:
Link UserSecurity[StoreID] to your main table (e.g., Orders[StoreID]).
UserSecurity[StoreID]
Orders[StoreID]
Create a role:
dax [StoreID] = LOOKUPVALUE( UserSecurity[StoreID], UserSecurity[UserEmail], USERPRINCIPALNAME() )
Verify only StoreID = 1 rows appear.
✅ Verification:- Log in as [email protected]—they should only see StoreID = 1 data.
Sales_East_Group
USERNAME() = "[email protected]"
LOOKUPVALUE()
FILTER()
WHERE StoreID IN (SELECT ...)
Sales_East → East Region Managers
RLS_Sales_East
Role1
.pbix
UserSecurity[StoreID] → Orders[StoreID]
"You have a sales dataset with a Region column. How do you ensure users only see their region’s data?"
[Region] = LOOKUPVALUE(UserSecurity[Region], UserSecurity[UserEmail], USERPRINCIPALNAME())
Static vs. Dynamic RLS:
"When should you use static RLS?"
DAX Function Traps:
"Which DAX function should you use for dynamic RLS in Power BI Desktop?"
Performance:
DOMAIN\username
Challenge:You have a Sales table with columns OrderID, StoreID, and Amount. Create a dynamic RLS role so that: - [email protected] sees only StoreID = 1.- [email protected] sees only StoreID = 2.
Sales
OrderID
Amount
StoreID = 2
Solution:1. Create a UserSecurity table: | UserEmail | StoreID | |--------------------|---------| | [email protected] | 1 | | [email protected] | 2 |
Why It Works:- LOOKUPVALUE() dynamically fetches the StoreID for the logged-in user.- USERPRINCIPALNAME() ensures the filter works in both Desktop and Service.
[Region] = "East"
[StoreID] = LOOKUPVALUE(UserSecurity[StoreID], UserSecurity[UserEmail], USERPRINCIPALNAME())
DOMAIN\user
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.