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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

UserName() and UserprincipalName() in Dyanmic RLS

Hello,

 

I have User table that contains username. And I have used that username to implement dynamic RLS.

its works fine with desktop with Username() or UserprincipalName(). 

 

But it not working in PowerBI service. I think powerBI service returns users email address instead of username. I am not sure why is happening but data is showing blank while testing using user's userName.

 

Do I need need to use Users Email address in my table to use in logic instead of username?.

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hello @Anonymous ,

 

yes, your guess is right. 

In Power BI Service both Username() and UserprincipalName() return the e-mail address.

 

See the notice from the row level security documentation:

 

You can use username() within this expression. Be aware that username() has the format of DOMAIN\username within Power BI Desktop. Within the Power BI service and Power BI Report Server, it's in the format of the user's User Principal Name (UPN). Alternatively, you can use userprincipalname(), which always returns the user in the format of their user principal name, username@contoso.com.

 

 

So you should change the table to the e-mail address and use UserprincipalName() already in Power BI Desktop to make the report work on both platforms in the same way.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi

View solution in original post

2 REPLIES 2
selimovd
Super User
Super User

Hello @Anonymous ,

 

yes, your guess is right. 

In Power BI Service both Username() and UserprincipalName() return the e-mail address.

 

See the notice from the row level security documentation:

 

You can use username() within this expression. Be aware that username() has the format of DOMAIN\username within Power BI Desktop. Within the Power BI service and Power BI Report Server, it's in the format of the user's User Principal Name (UPN). Alternatively, you can use userprincipalname(), which always returns the user in the format of their user principal name, username@contoso.com.

 

 

So you should change the table to the e-mail address and use UserprincipalName() already in Power BI Desktop to make the report work on both platforms in the same way.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi

Anonymous
Not applicable

Thanks @selimovd .

 

I too tested. need to Map users email-id only to implement RLS logic in PowerBI desktop to work similar in PowerBI service.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.