In this Power BI DAX Tutorial, we’ll explore the difference between USERNAME() and USERPRINCIPALNAME() in Power BI DAX functions.
We’ll also cover the syntax of these functions, how to use them in Power BI, and what they return in both Power BI Desktop and the Power BI service.
What is a username in Power BI?
In Power BI, the DAX function USERNAME returns the user’s domain login in the format (Domain\User) based on the locality or your local system.
When you use the USERNAME function in Power BI Service, it returns the current user’s login credentials in the format (e.g., Bijay@<tenant>.onmicrosoft.com).
Syntax:
USERNAME()
USERNAME function in Power BI Desktop
Now we see what the username function is returning in Power BI Desktop.
1. Open the Power BI Desktop. As you can see, we can’t use any DAX function without data.

2. Under the Home tab, click “Enter data“. Then, in the “Create Table” window, click the “Load” button.

3. Under the Home tab, click New measure.

4. In the formula bar, put the below expression.
User Name = USERNAME()

5. Under the Home tab, select Visual gallery, and select the Slicer visual icon.

6. Using the +Add data option, add the User Name into the Field.

7. The output will return the Domain with the user name locally, as shown in the screenshot below.

USERNAME function in Power BI Service
When we publish the above report in the Power BI Service, it will return the current user’s login credentials.

What is a userprincipalname in Power BI?
In Power BI, the DAX function USERPRINCIPALNAME returns the user’s domain login in the format (Domain\User) based on the locality or your local system.

When you use the USERPRINCIPALNAME function in Power BI Service, it returns the current user’s login credentials in the format (e.g., Bijay@<tenant>.onmicrosoft.com).

Syntax:
USERPRINCIPALNAME ()
Now we know that In Power BI Desktop (where reports are built), both functions display the format ‘work area and name’ (DOMAIN\username). In Power BI Service (where reports are viewed), both functions return the email address format (username@domain.com).
In this Power BI tutorial, we explored the difference between the USERNAME() and USERPRINCIPALNAME() functions. We covered their syntax, usage in Power BI, and what they return in both Power BI Desktop and the online service.
You may also like the following Power BI tutorials:
- Switch in DAX
- How to Apply Conditional Formatting in Power BI Pie Chart?
- Power BI Slicer Sort Descending
- How to Change yyyymmdd to Date Format in Power BI?
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com