Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DiKi-I
Post Partisan
Post Partisan

Row level security help

Can I use username() for row level security instead of userprincipalname(). I have ad user name in the table but not user email. Could you please let me know if this will work. Also my table is in direct query mode so I won't be able to modify the data.

1 ACCEPTED SOLUTION
Cookistador
Super User
Super User

yes this approach also works

 

just to be sure that the name your have in the table is in the right format

Create a measure _Test = Username()

 

Then add this measure in a card, to see how it is formatted vs what you have in the table (maybe you will have to add the domain in the list)

View solution in original post

7 REPLIES 7
v-csrikanth
Community Support
Community Support

Hi @DiKi-I 

We haven't heard from you since last response and just wanted to check whether the solution provided has worked for you. If yes, please Accept as Solution to help others benefit in the community.
Thank you.


If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.

v-csrikanth
Community Support
Community Support

Hi @DiKi-I 
I wanted to follow up since I haven't heard from you in a while. Have you had a chance to try the suggested solutions?
If your issue is resolved, please consider marking the post as solved. However, if you're still facing challenges, feel free to share the details, and we'll be happy to assist you further.
Looking forward to your response!

Best Regards,
Cheri Srikanth

v-csrikanth
Community Support
Community Support

Hi @DiKi-I 
It's been a while since I heard back from you and I wanted to follow up. Have you had a chance to try the solutions that have been offered?
If the issue has been resolved, can you mark the post as resolved? If you're still experiencing challenges, please feel free to let us know and we'll be happy to continue to help!
Looking forward to your reply!

If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.

v-csrikanth
Community Support
Community Support

Hi @DiKi-I 

In addition to @Idrissshatila @Cookistador below additional suggestions for implementing Row-Level Security (RLS) in Power BI.

  • Dynamic RLS using USERNAME() or USERPRINCIPALNAME(): Store user-to-data mappings in a table and filter based on the logged-in user dynamically.
  • Using security groups: Assign roles via Azure AD security groups and filter data based on group membership.
  • Testing RLS using "View as Role": Always validate roles in Power BI Desktop before publishing.
  • Combining static and dynamic RLS: Use hybrid logic for more complex access control scenarios.


If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.

 

Idrissshatila
Super User
Super User

Hello @DiKi-I ,

 

make sure to test it in the view role before applying it, since this is a sensitive case.



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




my username is getting resolved to upn in service. I will test with the actual data once I have gateway setup.

Cookistador
Super User
Super User

yes this approach also works

 

just to be sure that the name your have in the table is in the right format

Create a measure _Test = Username()

 

Then add this measure in a card, to see how it is formatted vs what you have in the table (maybe you will have to add the domain in the list)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.