Downloads
DAXInformationBeginner

USERNAME

Returns the name of the user who is connected to the model.

Syntax
USERNAME()

Returns: Text (a scalar). The exact form depends on where the model runs.

What it does

USERNAME returns the name of the person who is using the model, as the host knows it. It is used to stamp a report with the name of the reader, or to look up the user's settings in a table. The exact text varies: a domain and user name in some hosts, a sign in name in others. Test it in the environment where the report will run.

Syntax and arguments

USERNAME takes no arguments. Write USERNAME() with brackets.

Example

A close checklist is printed for sign off. The footer should show who printed it, to create a simple record of the person who took the view.

Prepared By = "Prepared by " & USERNAME()

The footer reads "Prepared by" followed by the user's name as the host supplies it. The name is generated when the report is viewed, so the footer changes for each reader.

Example: a second, different use

Show a user's own region by looking their name up in a table of user settings:

My Region =
LOOKUPVALUE(
    UserRegions[Region],
    UserRegions[UserName],
    USERNAME()
)

LOOKUPVALUE finds the row whose user name matches, and returns that row's region. If the user is not in the table, the result is BLANK.

Things to watch

In business terms

USERNAME stamps reports with who viewed or prepared them, and it lets a model show each reader only their own unit when the lookup list is kept up to date. Auditors look for this kind of trail on a report that others will rely on.

Related functions

All DAX functions · View as Markdown · DAX fundamentals