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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
edumach
Helper I
Helper I

Return full username

I have a table that has the username, name among other information, I want to get the username from the pbi and cross it with this table and return the other information of this user

 

I want to cross Username with Login_AD and return First_Name_AD

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @edumach 

As I mentioned before, UserName() will return Domain\Name in Power BI Desktop. UserPrincipalName() will return email format like UserA@xxx.com in Power BI Desktop.

Both of UserName() and UserPrincipalName() will return email format to show UPN(Current user login in Power BI Service) in Power BI Service. 

My Test:

CurrentName = CALCULATE(MAX('Table'[Name]),FILTER('Table','Table'[Domain\Name] = [CurrentUser]))

In Desktop, UserName() will return Domain\Name, so measure works well.

1.png

In Service, UserName() will return a email format and measure won't work.

2.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @edumach ,

 

I think you can use Row-Level-Security to restrict data access for given users. Your end user could only see values belong to them after you set RLS in Power BI. What does [Username] looks like, only name or email format? We will use UserName() or UserPrincipalName() Function to get Login_AD. 

 

UserName() will return Domain\Name in Power BI Desktop. UserPrincipalName() will return email format like UserA@xxx.com. Both of them will return email format in Power BI Service. So here I suggest you to use UserPrincipalName(). And you need a Email format column in your table.

 

My Sample:

1.png

Manage role in Desktop:

2.png

Test Result:

3.png

You need to add the user in Role in Security in Dataset after you publish this report to Power BI Service.

For reference:

Manage security on your model

Note: Workspace members assigned AdminMember, or Contributor have edit permission for the dataset and, therefore, RLS doesn’t apply to them.

Here is a blog about dynamic RLS in power bi.

Dynamic Row Level Security with Power BI Made Simple Posted on July 4, 2016

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous I understand your example, but I believe I have not been clear on my problem, what I need is to take the username function that returns the pbi user in domain\user format and look for that user in another table and return the full name.

Anonymous
Not applicable

Hi @edumach 

As I mentioned before, UserName() will return Domain\Name in Power BI Desktop. UserPrincipalName() will return email format like UserA@xxx.com in Power BI Desktop.

Both of UserName() and UserPrincipalName() will return email format to show UPN(Current user login in Power BI Service) in Power BI Service. 

My Test:

CurrentName = CALCULATE(MAX('Table'[Name]),FILTER('Table','Table'[Domain\Name] = [CurrentUser]))

In Desktop, UserName() will return Domain\Name, so measure works well.

1.png

In Service, UserName() will return a email format and measure won't work.

2.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous Excellent, this solution worked perfectly.

as @Anonymous was pointing out you won't get that in the Power BI service. The service "only" gives you the email address. You need to base your lookups on that.

lbendlin
Super User
Super User

please provide more details. What have you tried and where are you stuck?

Get the usurname from the powerbi session and look it up in the table user and return the name.

Example.PNG

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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