0
0
Power BIbi_tool~20 mins

Dynamic RLS with USERNAME in Power BI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Dynamic RLS Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
dax_lod_result
intermediate
2:00remaining
DAX Measure Output with USERNAME() in Dynamic RLS

Consider a table Sales with columns SalesAmount and UserEmail. A dynamic RLS filter uses USERNAME() to filter rows where UserEmail matches the logged-in user.

Given this DAX measure:

Filtered Sales = CALCULATE(SUM(Sales[SalesAmount]), Sales[UserEmail] = USERNAME())

If the logged-in user is john.doe@company.com and the Sales table has these rows:

  • (100, "john.doe@company.com")
  • (200, "jane.smith@company.com")
  • (150, "john.doe@company.com")

What is the value of Filtered Sales?

Power BI
Filtered Sales = CALCULATE(SUM(Sales[SalesAmount]), Sales[UserEmail] = USERNAME())
A250
B450
C200
D0
Attempts:
2 left
💡 Hint

Think about which rows match the USERNAME() filter.

visualization
intermediate
2:00remaining
Best Visualization for Dynamic RLS User Sales Summary

You want to create a Power BI report page that shows each logged-in user only their own sales summary using dynamic RLS with USERNAME(). Which visualization type is best to clearly show the total sales amount for the current user?

AStacked bar chart showing sales by all users
BScatter plot of sales amount vs. user email
CCard visualization showing total sales amount
DTable showing sales for all users
Attempts:
2 left
💡 Hint

Think about a simple, clear way to show a single number filtered by RLS.

data_modeling
advanced
2:30remaining
Designing a Dynamic RLS Model with USERNAME() and Role Table

You have a Users table with columns UserEmail and Region. Your Sales table has a Region column. You want to apply dynamic RLS so each user sees only sales from their region.

Which DAX filter expression correctly implements this dynamic RLS in the role definition?

ASales[Region] = LOOKUPVALUE(Users[UserEmail], Users[Region], USERNAME())
BFILTER(Sales, Sales[Region] = LOOKUPVALUE(Users[Region], Users[UserEmail], USERNAME()))
CSales[Region] = USERNAME()
DFILTER(Users, Users[UserEmail] = Sales[Region])
Attempts:
2 left
💡 Hint

Think about matching the sales region to the user's region found by USERNAME().

🔧 Formula Fix
advanced
2:00remaining
Identify the Error in Dynamic RLS Using USERNAME()

Given this RLS filter expression in Power BI:

Sales[UserEmail] = USERNAME()

Users report that after publishing, no data is visible for any user. What is the most likely cause?

AUSERNAME() returns the user's email but the filter should use USERPRINCIPALNAME()
BThe filter syntax is invalid and causes a syntax error
CSales[UserEmail] column is missing from the model
DUSERNAME() returns domain\username but UserEmail stores email addresses, causing no matches
Attempts:
2 left
💡 Hint

Consider the format of USERNAME() output versus stored emails.

🧠 Conceptual
expert
3:00remaining
Scenario: Combining Dynamic RLS with Hierarchical Roles

Your company has a hierarchy of users: regional managers and sales reps. Sales reps should see only their own sales. Regional managers should see sales for all reps in their region.

You have a Users table with UserEmail, Region, and Role columns. Sales have a SalesRepEmail and Region.

Which approach best implements dynamic RLS to meet these requirements?

ACreate two roles: one filters sales where SalesRepEmail = USERNAME(); the other filters sales where Region = LOOKUPVALUE(Users[Region], Users[UserEmail], USERNAME())
BCreate one role filtering sales where SalesRepEmail = USERNAME() OR Region = USERNAME()
CCreate a role filtering sales where SalesRepEmail = LOOKUPVALUE(Users[UserEmail], Users[Role], "SalesRep")
DCreate roles with no filters and rely on report page filters to limit data
Attempts:
2 left
💡 Hint

Think about how to separate access by role and region using dynamic filters.