Greg_Deckler's avatar
Greg_Deckler
Community Champion
8 years ago

Greeting

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)

 

 

 

3 Replies

  • This is great, thanks Greg_Deckler, my list of names was pulled from Active Directory. I like the little extra flourish of the time of day prefix.

  • Anonymous's avatar
    Anonymous
    Not applicable

    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.

    • Anonymous's avatar
      Anonymous
      Not applicable

      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