cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
deepu299
Helper V
Helper 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
Post Prodigy
Post Prodigy

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?

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

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.

 

 

gajju
Frequent Visitor

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

snagaboina
Frequent Visitor

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
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.