Forum Discussion
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)
8 Replies
- StachuCommunity Champion
USERNAME() has the domain as a prefix, do you account for that in your table?
https://docs.microsoft.com/en-us/dax/username-function-daxyou can also try with USERPRINCIPALNAME()
https://dax.guide/userprincipalname/
Did I answer your question? Mark my post as a solution!
Proud to be a Datanaut!
- AnonymousNot applicable
Both functions that you have mentioned doesn't return me any family name. I am little unsure if it can actually be retrieved?
- StachuCommunity Champion
I assumed that you have some dictionary table that allows to find the name based on the USERNAME() or the other function. Is that correct?
Usernames don't have to be based on the names/surnames, so returning the id seems the logical solution here
Did I answer your question? Mark my post as a solution!
Proud to be a Datanaut!