Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Finding First Name or Last name using DAX like @Username

Hi, 

I understand that PowerBI records name of all the users who are logged into the app. I am using RLS on username 

I want to develop a greeting where I greet them with their name such as:

 

Good Afternoon Usman

 

Is it possible?

I found this solution but it doesn't work. 

 

Greeting1 = 
VAR user = USERNAME()
VAR display = LOOKUPVALUE(Table1[User],Table1[Email],user)
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,display)