Downloads
DAXInformationIntermediate

USERPRINCIPALNAME

Returns the user principal name of the person connected to the model, usually the sign in email address.

Syntax
USERPRINCIPALNAME()

Returns: Text (a scalar).

What it does

USERPRINCIPALNAME returns the user principal name (UPN) of the signed in user. In most business setups this is the sign in email address. It is the stable identity to use in a lookup table that controls who sees what. It is the usual input to row level security designs, where a permissions table lists which user may see which region.

Syntax and arguments

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

Example

A permissions table lists each controller and the business unit they may view. Each measure should show only the figures for the units that the signed in user is allowed to see.

Allowed Sales =
CALCULATE(
    [Total Sales],
    FILTER(
        UserUnits,
        UserUnits[UserPrincipalName] = USERPRINCIPALNAME()
            && UserUnits[Unit] = SELECTEDVALUE(Units[Unit])
    )
)

For each unit, the measure checks that the user has access to it. A unit the user cannot see produces no rows, so no figure. This is a display pattern. The strong control is row level security set on the model roles, so the rule holds in every report.

Example: a second, different use

Look up the approver's region from the same identity, to decide which regional approvals the user sees:

My Region =
LOOKUPVALUE(
    UserRegions[Region],
    UserRegions[UserPrincipalName],
    USERPRINCIPALNAME()
)

LOOKUPVALUE returns the region tied to the signed in email. If the user has no row, the result is BLANK.

Things to watch

In business terms

USERPRINCIPALNAME supports finance reports where each person should see only their entity, cost center or client group. It is the bridge between the sign in and the permissions list that a controller signs off on, and it is the first thing an auditor asks about in a report access review.

Related functions

All DAX functions · View as Markdown · DAX fundamentals