26.4 Testing RLS
Quick answer: the short, self-contained version of this lesson is the guide Row-Level Security in Power BI.
Start with a problem
Ravindra published RLS but did not test it. A manager saw another city's data.
Explain simply
Test in Desktop with View as and in the Service with Test as role, using real emails.
Show the data
| User (email) | City in security table | Rows visible | Total Sales (₹) |
|---|---|---|---|
| ravindra@example.com | Pune | 301, 302, 306 | 850 |
| shraddha@example.com | Nashik | 303, 304, 307 | 800 |
| zoya@example.com | Kolhapur | 305, 308 | 450 |
| salman@example.com | Pune, Nashik | 6 orders | 1,650 |
| Rani (no role, workspace Viewer with all-cities role) | All | 301–308 | 2,100 |
About this data: This table uses columns: User (email), City in security table, Rows visible, Total Sales (₹). This table uses columns: Wrong result, Reason, Correction. Values shown are the lesson examples already on this page (not a new dataset).
Fictional sample data. Practice file: rls_user_security.csv (source: src/practice/).
Demonstrate
- Desktop › Modeling › View as › role + Other user ravindra@example.com.
- Check card ₹850.
- Service › model › Security › role › Test as role.
- Repeat for each user in the table.
Show the result
Your result should look like this (fictional sample):
| User (email) | City in security table | Rows visible | Total Sales (₹) |
|---|---|---|---|
| ravindra@example.com | Pune | 301, 302, 306 | 850 |
| shraddha@example.com | Nashik | 303, 304, 307 | 800 |
| zoya@example.com | Kolhapur | 305, 308 | 450 |
| salman@example.com | Pune, Nashik | 6 orders | 1,650 |
| Rani (no role, workspace Viewer with all-cities role) | All | 301–308 | 2,100 |
Explain what happened
Testing simulates the user's security filter before go-live.
Explore further
- Keep a test checklist with expected totals.
Detailed reference for this lesson:
In Desktop: Modeling › View as › tick a role (and/or tick Other user and type an e-mail such as zoya@example.com to test dynamic RLS) › OK. A yellow bar shows "Now viewing as…". Check that cards and tables show only Kolhapur data (Rajarampuri and Tarabai Park stores). Click Stop viewing to return.
In the Service:
- Publish the report.
- In the workspace, open the semantic model's … › Security.
- Select each role and add members – individual users or (better) security groups.
- Use … › Test as role to check the result, optionally as a specific person.
Test kelyashivay RLS publish karu naka – bilkul nahi!
Ravindra Bagale's Tip
Friends, many students publish RLS without testing it with View as in Desktop and Test as role in the Service. Test every role, including a user who should see nothing and a user with several cities. Check totals, not just the list of cities. Never forget this.
Ravindra Bagale's Tip – मराठी
मित्रांनो, बरेच students Desktop मध्ये View as आणि Service मध्ये Test as role ने test न करता RLS publish करतात. प्रत्येक role test करा, ज्याला काहीच दिसू नये असा user आणि अनेक cities असलेला user यांच्यासह. फक्त cities ची list नाही, totals पण चेक करा. हे अजिबात विसरू नका.
Ravindra Bagale's Tip – हिंदी
दोस्तों, बहुत से students Desktop में View as और Service में Test as role से test किए बिना RLS publish कर देते हैं. हर role test करो, उस user सहित जिसे कुछ नहीं दिखना चाहिए और कई cities वाले user सहित. सिर्फ़ cities की list नहीं, totals भी check करो. यह बिल्कुल मत भूलना.
Fix common mistakes
| Wrong result | Reason | Correction |
|---|---|---|
| Tested as Admin, saw all | Edit roles bypass RLS | Test with View as |
| Expected ₹850 but ₹2,100 | Role not selected | Select role and user |
| Totals right, details wrong | Only card tested | Test tables too |
Practise independently
Practice task
Expected total for shraddha@example.com?
Hints
- Nashik.
Solution
₹800.
Think like a professional
A written RLS test table with expected numbers is strong evidence of quality.
Revision card