Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
04-05-2018 06:44 AM - last edited 06-26-2018 09:52 AM
Create a personalized greeting for your users with this Quick Measure. Uses USERNAME function so that doesn't work so well with Publish To Web.
Greeting =
VAR user = USERNAME()
VAR hour = HOUR(NOW())
VAR minute = MINUTE(NOW())
VAR prefix = SWITCH(
TRUE(),
hour<12,"Good morning ",
hour<17,"Good afternoon ",
"Good evening "
)
RETURN CONCATENATE(prefix,user)
Place this measure in a Card visualization.
If you have a lookup table of user names and friendly display names, you can do this:
Greeting1 =
VAR user = USERNAME()
VAR display = LOOKUPVALUE(Table1[User],Table1[Email],user)
VAR display1 = IF(ISBLANK(display),"Player One", display)
VAR hour = HOUR(NOW())
VAR minute = MINUTE(NOW())
VAR prefix = SWITCH(
TRUE(),
hour<12,"Good morning ",
hour>=12 && hour<17,"Good afternoon ",
"Good evening "
)
RETURN CONCATENATE(prefix,display1)
eyJrIjoiMjNiMmYxMWQtMDc2OC00ZGY0LWE4NDctZWFlMWU3MjExNzQ4IiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9
Basically I would expect Power BI Pro to supply somehow the user first and last name through a DAX call or something else.
I understand what you proposed though it just would not give me what I want wthout having another table loaded with names with a reference from USERNAME().
Thanks anyway for the response.
Hello,
Just a quick tip. In case username is an email address (I assume typically this is the case), first name can be extracted with these two variables:
var vFirstNameDigit = SEARCH(".",USERNAME())-1
var vFirstName = LEFT(USERNAME(),vFirstNameDigit)
BR
Harri