How it works...

The key to this recipe is the USERNAME DAX function. This function retrieves the user that is logged on to Power BI. On premises, this may appear in the domain/account format, while online, this will appear as your email address. The results of this function are stored in the __User variable.

Next, we retrieve the current hour of the day using the HOUR and NOW DAX functions. NOW retrieves the current date and time, while HOUR provides us with the integer value from 0-23, representing the hour of the current time.

We can now use a relatively simple SWITCH statement to determine whether the current time is in the morning, afternoon, or evening, and store a pleasant greeting in the __Prefix variable.

Finally, we simply use the DAX CONCATENATE function to RETURN the __Prefix and __User variables as a single string value.