In this Power BI DAX Tutorial, We will discuss what is the difference between USERNAME() and USERPRINCIPALNAME() in the Power BI DAX Function.
Also, we will see the syntax of USERNAME() and USERPRINCIPALNAME() Power BI functions. How to use USERNAME() and USERPRINCIPALNAME() in Power BI and what it returns in the Power BI Desktop and as well as Power BI Online Service.
USERNAME() Vs. USERPRINCIPALNAME()
The Power BI DAX USERNAME() function helps to return the user domain login with the form of (Domain\User) in the locality or your local system.
The Power BI DAX USERPRINCIPALNAME() function helps to return the user principal name with the form of (User’s login credential or Preeti@<tenant>.onmicrosoft.com) in the Power BI Online Service.
Below represents the syntaxes of USERNAME() and USERPRINCIPALNAME() Function:
To apply the syntax functions, at first, you need to create a New measure and put the below formula into it.
USERNAME() Power BI Function Syntax
User Name = USERNAME()
- User Name = Measure Name
- USERNAME() = Function of the User name
USERPRINCIPALNAME() Power BI Function Syntax
User Principal Name = USERPRINCIPALNAME()
- User Principal Name = Measure Name
- USERPRINCIPALNAME = Function of the User Principal Name
What it Returns
When you will apply the USERNAME() and USERPRINCIPALNAME() DAX Function, then it returns the user domain login (Domain\User) in the Power BI Local Desktop.
But in the Power BI Online Service, both of the DAX Functions return the user name with the login credentials.
In Power BI Desktop
At first, Create two New Measures and apply the USERNAME() and USERPRINCIPALNAME() function formulas in each of the formula bars.
Add a Table under the Visualizations section, then the output will return the Domain with the user name in locally as the below screenshot.
In Power BI Online Service
Publish the Power BI Report in your Local Desktop and Sign in your Power BI Online service account in the browser.
Open your Power BI Report, then you can see the user name with your login credentials as shown below.
Also, you may like the below Power BI tutorials:
- How to create and use Power BI Bookmarks
- What is the difference between calculated column and measure in Power BI
- Power bi free vs pro vs premium
- PowerBI Report Filter using Slicer Visualization
- Get Month Name from Month Number in Power BI
- Power bi conditional column example
- Power BI report using People Picker Field
- Export Power BI reports to PDF
- Remove blank from Power bi slicer
In this Power BI DAX Tutorial, We discussed what is the difference between USERNAME() and USERPRINCIPALNAME() in the Power BI DAX Function.
Also, we saw what are the syntaxes of both the functions, How you can use it and what it returns in the Power BI Desktop and as well as Power BI Online Service.
Hello Everyone!! I am Bhawana a SharePoint MVP and having about 10+ years of SharePoint experience as well as in .Net technologies. I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools. Now exploring more in SharePoint 2016 🙂 Hope here I can contribute and share my knowledge to the fullest. As I believe “There is no wealth like knowledge and no poverty like ignorance”