Dashboard Mode - Dynamic RLS with USERNAME
Business Question
How can we show sales data only for the logged-in user using dynamic row-level security (RLS) with the USERNAME function?
How can we show sales data only for the logged-in user using dynamic row-level security (RLS) with the USERNAME function?
| UserEmail | Region | SalesAmount | OrderDate |
|---|---|---|---|
| alice@example.com | North | 1000 | 2024-01-15 |
| bob@example.com | South | 1500 | 2024-02-20 |
| alice@example.com | East | 700 | 2024-03-05 |
| carol@example.com | West | 1200 | 2024-01-30 |
| bob@example.com | North | 900 | 2024-04-10 |
Total Sales = SUM(Sales[SalesAmount])Sales[UserEmail] = LOWER(USERNAME())
This expression filters the Sales table rows to only those where the UserEmail matches the logged-in user's email.
+----------------------+----------------------+ | KPI Card | Bar Chart | | Total Sales Amount | Sales by Region | +----------------------+----------------------+ | Sales Details Table | +-------------------------------------------------+
The dynamic RLS filter automatically applies based on the logged-in user's email. No manual slicers are needed to filter data by user.
All visuals (KPI card, bar chart, and table) update automatically to show only data for the current user.
If you log in as bob@example.com, which rows appear in the Sales Details table?
Answer: Only rows where UserEmail is bob@example.com (rows 2 and 5 from the sample data).
All visuals update to show sales totals and regions only for Bob's data.