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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
deepu299
Advocate V
Advocate V

Power bi desktop Username() shows windows user

I have connected Live to SSAS tabular database with RLS enabled. When I create a measure in power bi desktop as Measure=Username() , it is displaying admin user from windows machine instead of the user who actually logged into power bi desktop. Say USER1 is admin on windows machine. USER2 logged into power bi desktop. I expect Username() to show USER2 but it is showing USER1. 

 

Where does the Username() gets value from? Also  USER2 is not part of RLS, still he is able to query all the data. 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @deepu299,

 

I think you have misunderstand with USERNAME function, current it will return the stored connection credentials.

Returns the domain name and username from the credentials given to the system at connection time

 

As you said, you are connect with USER1(Admin) account, so admin credentials will cached in pbix files, it not effected by power bi account.

 

USERNAME Function (DAX)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

8 REPLIES 8
ToddChitt
Super User
Super User

I think the USERNAME() and USERPRINCIPALNAME() functions are somewhat misleading, and/or need enhancements. How about a function called "SIGNEDINUSER()" (Signed-In-User) that returns the username, in appropriate format, of the account that has been used to sign in to Power BI Desktop?

 

I too ran into some trouble trying to troubleshoot Row Level Security while signed in to Power BI Desktop using credentials supplied by a Client. (I.E.: NOT my corporate credentials). 

 

Power BI Desktop obviously KNOWS who is signed in as it uses that info when you go to publish. So why can't we have a DAX function that RETURNS that value?




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





v-shex-msft
Community Support
Community Support

Hi @deepu299,

 

I think you have misunderstand with USERNAME function, current it will return the stored connection credentials.

Returns the domain name and username from the credentials given to the system at connection time

 

As you said, you are connect with USER1(Admin) account, so admin credentials will cached in pbix files, it not effected by power bi account.

 

USERNAME Function (DAX)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Is there any other function that display log in user info. I am trying to apply row level security based on the logged in user. 

Are you having any issues with USERNAME() function? It gives the output in Domain/Username format. You could also try the function USERPRINCIPALNAME. 

I tried with the both. But instead of actual logged in user its showing information of service account which used in datasource connection. my data source is SSAS cube. If I use direct table its working as expected. Only problem with report build on top of cube.

This issue is resolved aftering changin the domain to one exists in out AD group. In our case its @Mydomain. com to @Mydomain.local. 

 

The way it works is, what ever the login ID that we use for access the powerbi first get verified with AD UPN or Effective user name. If if its not able to find any match it will show blank data. So we need to handle in power bi service and convert to one that matches company AD. in my case I have firstname.lastname@mydomain.com , But our company AD maintain as networkID@mydomain.local.

so I have to convert to networkID using the mapping. 

for bulk replacement we can modify the file on 'On-premises gateway'  to lookup email and replace with User principal name'

 

Hope this helps.

 

 

Anonymous
Not applicable

Hi  @snagaboina,

  i face the same issue .

could you elaborate on the Fix you did.

I tried both username and userprincipal name .

it always opens with my account even if i share the report to another user

my company id is name @ company.com

Under Map user Names did you select 'Effect User Name' ? Otherwise it always shows whatever the credentials that you used for creating the database connection.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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