Bird
Raised Fist0
Power BIbi_tool~10 mins

Why RLS protects sensitive data in Power BI - Formula Trace Breakdown

Choose your learning style10 modes available
Sample Data

This table shows employees with their IDs, names, departments, and salaries.

CellValue
A1EmployeeID
B1Name
C1Department
D1Salary
A2101
B2Alice
C2Sales
D270000
A3102
B3Bob
C3HR
D365000
A4103
B4Charlie
C4Sales
D472000
A5104
B5Diana
C5IT
D580000
Formula Trace
FILTER(Employee, Employee[Department] = USERPRINCIPALNAME())
Step 1: USERPRINCIPALNAME()
Step 2: Employee[Department] = "Sales"
Step 3: FILTER(Employee, [TRUE, FALSE, TRUE, FALSE])
Cell Reference Map
    A       B       C       D
1 |EmployeeID | Name  | Department  | Salary
2 | 101  | Alice | Sales | 70000 
3 | 102  | Bob   | HR    | 65000 
4 | 103  | Charlie| Sales| 72000 
5 | 104  | Diana | IT    | 80000 

User's department: Sales (used in filter)
The formula uses the Department column to filter rows matching the user's department.
Result
    A       B       C       D
1 |EmployeeID | Name  | Department  | Salary
2 | 101  | Alice | Sales | 70000 
4 | 103  | Charlie| Sales| 72000 
The filtered table shows only employees from the Sales department, hiding others.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does USERPRINCIPALNAME() return in this example?
A"Alice"
B"Sales"
C"HR"
D"70000"
Key Result
FILTER(table, table[column] = USERPRINCIPALNAME()) filters rows to show only data matching the current user.

Practice

(1/5)
1. What is the main purpose of Row-Level Security (RLS) in Power BI?
easy
A. To speed up data refresh times
B. To change the visual design of the report for each user
C. To create new calculated columns automatically
D. To restrict data access by filtering rows based on the user's identity

Solution

  1. Step 1: Understand RLS functionality

    RLS filters data rows so users only see data they are allowed to access.
  2. Step 2: Compare options

    Speeding up refresh times, changing visual design, and creating calculated columns describe unrelated features; only restricting data access by filtering rows based on user identity matches RLS purpose.
  3. Final Answer:

    To restrict data access by filtering rows based on the user's identity -> Option D
  4. Quick Check:

    RLS filters rows by user identity = C [OK]
Hint: RLS controls data visibility per user, not report design [OK]
Common Mistakes:
  • Confusing RLS with report formatting
  • Thinking RLS speeds up data refresh
  • Believing RLS creates new columns
2. Which of the following is the correct way to define a filter in a Power BI RLS role?
easy
A. FILTER('Sales', 'Sales'[Region] = "USERNAME()")
B. FILTER('Sales', 'Sales'[Region] == USERNAME())
C. FILTER('Sales', 'Sales'[Region] = USERPRINCIPALNAME())
D. FILTER('Sales', 'Sales'[Region] = USERNAME())

Solution

  1. Step 1: Identify correct DAX function for user identity

    USERPRINCIPALNAME() returns the logged-in user's full username, commonly used in RLS filters.
  2. Step 2: Check syntax correctness

    FILTER('Sales', 'Sales'[Region] = USERPRINCIPALNAME()) uses correct syntax and function. Using double equals (==), treating the function as a string, or using USERNAME() instead misuses syntax or less preferred function.
  3. Final Answer:

    FILTER('Sales', 'Sales'[Region] = USERPRINCIPALNAME()) -> Option C
  4. Quick Check:

    Use USERPRINCIPALNAME() for RLS filters = A [OK]
Hint: Use USERPRINCIPALNAME() for user-based filters in RLS [OK]
Common Mistakes:
  • Using USERNAME() instead of USERPRINCIPALNAME()
  • Using double equals (==) in DAX
  • Putting USERNAME() inside quotes
3. Given this RLS filter on the 'Sales' table:
FILTER('Sales', 'Sales'[Salesperson] = USERPRINCIPALNAME())
If the logged-in user is 'alice@example.com', what data will Alice see?
medium
A. All sales data regardless of salesperson
B. Only sales where 'Salesperson' equals 'alice@example.com'
C. No data because USERPRINCIPALNAME() is invalid
D. Sales data for all salespersons except 'alice@example.com'

Solution

  1. Step 1: Understand the filter condition

    The filter keeps rows where 'Salesperson' matches the logged-in user's email.
  2. Step 2: Apply the filter for user 'alice@example.com'

    Only rows with 'Salesperson' = 'alice@example.com' remain visible to Alice.
  3. Final Answer:

    Only sales where 'Salesperson' equals 'alice@example.com' -> Option B
  4. Quick Check:

    RLS shows user-specific rows = B [OK]
Hint: RLS filters rows matching logged-in user exactly [OK]
Common Mistakes:
  • Assuming all data is visible
  • Thinking USERPRINCIPALNAME() is invalid
  • Believing data for other users is shown
4. You created this RLS role filter:
FILTER('Orders', 'Orders'[Country] = USERNAME())
But users report seeing no data. What is the most likely issue?
medium
A. USERNAME() returns only the username, not the country name
B. FILTER function is not supported in RLS roles
C. The table name 'Orders' is misspelled
D. RLS roles cannot filter by text columns

Solution

  1. Step 1: Understand USERNAME() output

    USERNAME() returns the user's login name, not a country name.
  2. Step 2: Compare USERNAME() with 'Country' column

    Since 'Country' contains country names, the filter never matches, so no data shows.
  3. Final Answer:

    USERNAME() returns only the username, not the country name -> Option A
  4. Quick Check:

    Mismatch between USERNAME() and column values = A [OK]
Hint: Match USERPRINCIPALNAME() or correct user info to column values [OK]
Common Mistakes:
  • Assuming USERNAME() returns country
  • Thinking FILTER is unsupported in RLS
  • Ignoring case sensitivity in filters
5. You want to protect sensitive sales data so that each regional manager sees only their region's data. Which approach best uses RLS to achieve this?
hard
A. Create a role with filter 'Sales'[Region] = LOOKUPVALUE('Managers'[Region], 'Managers'[Email], USERPRINCIPALNAME()) and assign managers by email
B. Do not use RLS; instead, create separate reports for each region
C. Create a role with filter 'Sales'[Region] = "Region1" and assign all managers to this role
D. Create a role with filter 'Sales'[Region] = USERPRINCIPALNAME() and assign managers their email as region

Solution

  1. Step 1: Understand the need for dynamic filtering

    Each manager should see data for their assigned region, which may differ from their username.
  2. Step 2: Use LOOKUPVALUE to map manager email to region

    Create a role with filter 'Sales'[Region] = LOOKUPVALUE('Managers'[Region], 'Managers'[Email], USERPRINCIPALNAME()) and assign managers by email uses LOOKUPVALUE to find the manager's region from a 'Managers' table, enabling correct filtering.
  3. Step 3: Evaluate other options

    Create a role with filter 'Sales'[Region] = USERPRINCIPALNAME() and assign managers their email as region incorrectly assumes email equals region; C assigns all managers to one region; B avoids RLS and is less efficient.
  4. Final Answer:

    Create a role with filter 'Sales'[Region] = LOOKUPVALUE('Managers'[Region], 'Managers'[Email], USERPRINCIPALNAME()) and assign managers by email -> Option A
  5. Quick Check:

    Use LOOKUPVALUE for dynamic RLS filtering = D [OK]
Hint: Use LOOKUPVALUE to map users to their data dynamically [OK]
Common Mistakes:
  • Assuming username equals region directly
  • Assigning all users to one static region
  • Avoiding RLS and duplicating reports
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard