Replace USERPRINCIPLE NAME with custom name

So I am doing some cool things to the reports to add flavor. What I have done is added a Greeting to the cover page of the reports so that it displays the USERPRINCIPLENAME() for the logged in individual along with a greeting based on time of day. For my organization, the USERPRINCIPLENAME() is the email address and not the actual name.

Is it possible for me to create a table that has the individuals email address and their display name and some get it to use the display name instead of the USERPRINCIPLENAME()?

So instead of displaying Good Afternoon jmwdba@domain.com it will display Good Afternoon Michael Williams.

My current formula is:

Greeting =

VAR user = USERPRINCIPALNAME()

Var hour = HOUR(NOW())

VAR minute = MINUTE(NOW())

VAR prefix = SWITCH(

TRUE(),

hour<12, “Good Morning”,

hour<17, “Good Afternoon”,

“Hello”

)

RETURN CONCATENATE(prefix&" ", user)

I think this should definitely be possible, even though I’ve never done this myself.

You would just need to create the table,

Then within this formula use the variable you have generated for ‘user’ as a search name rather than the ultimate result.

So all the logic you would need is something like the below

CALCULATE( SELECTEDVALUE( actualusername),
FILTER( Newusertable, emailaddresscolumn = ‘user variable’ )

That’s it really…this should get you what you require from what I can imagine right now.

1 Like

This worked like a charm. If anyone else is interesting in applying this unique customization to any of their reports, below are the formulas and steps used.

STEP 1: Create a User table.
In the case of my table, I have a field for the Email (which is also the userprinciplename() for my organization) and I have a column called Display name which is the name I actually want to show.

STEP 2: Create Display name Formula

Display User = 
CALCULATE( SELECTEDVALUE(Users[Display Name]),
	FILTER(Users, Users[Email]= USERPRINCIPALNAME()))

STEP 3: Create The Greeting

Greeting =
VAR user = [Display User]
VAR hour = HOUR(NOW())
VAR minute = MINUTE(NOW())
VAR prefix = SWITCH(
TRUE(),
hour<12, “Good Morning”,
hour<17, “Good Afternoon”,
“Good Day”
)
RETURN CONCATENATE(prefix&" ", user)

I also came across the issue where the Message based on time of day was correct on the desktop but when uploaded to the Power BI Service it was wrong. So the the below article helps solve this problem:

Nice concept , how do you create step 1?

using function on custom table is not supported and i would like to do same thing but storing the username/principal name is the issue for me…

any help

I actually used the “Enter Data” inside of Power BI I named the table ‘Users’ and created the columns “Email”, “Display Name” and “Official Name”. For my organization our userprinciplename() is our “Email”.

Thanks boss.

It seem you manually type all the names in.

I thought you used the function (userprinciplename() ) inside of the column you created.

In my Display User Formula that is where in the filter you tell it when the User[Email] = userprinciplename() then give the selected value Users[Display Name]. So that is your link between the email address in the Users table and the userprinciplename(). I did when creating the “Email” column or really just bring in an existing spreadsheet that has all that information if you have a larger number of users. In my case, I only have 50 users to bring in so it was faster to just type it.

Display User =
CALCULATE( SELECTEDVALUE(Users[Display Name]),
FILTER(Users, Users[Email]= USERPRINCIPALNAME()))

Seen… Thanks.