Forum Discussion
Finding First Name or Last name using DAX like @Username
Okay this makes sense, so in that case, I have following columns in my dataset.
| Name | Companyemail |
| John Smith | [email protected] |
| Brown Fox |
Given the above table, can we do that it searches for Username in company email, and if matches, display Name? If yes, what would be the dax?
what format does USERPRINCIPALNAME() return for you? I assume it would be something like [email protected]
If that's the case then this should work:
HelloUser =
"Hello "
& CALCULATE (
FIRSTNONBLANK ( 'Table'[Name], TRUE ),
'Table'[Companyemail] = USERPRINCIPALNAME ()
)
Proud to be a Datanaut!
- Anonymous7 years agoNot applicable
Thanks for helping out, however it doesn't seem to be working. It only returns "HelloUser", that's all, and yes userprincipalname returns me email such as [email protected].
Btw I am using Username for Dynamic RLS and not userpricipalname- Stachu7 years agoCommunity Champion
it cannot return HelloUser beacause that's the measure name - have you added this syntax as a new measure? It's completely unrelated to RLS
Did I answer your question? Mark my post as a solution!
Proud to be a Datanaut!
- aggregator30004 years agoAdvocate II
Hi Anonymous , this is probably long ago solved however adding some value for other searchers.
Stachu solution working well over here, but a small alteration needed on your key.
Recommend using UserPrincipalName() instead for easier consistency
Username() value output is a little volatile as PBI Service will revert it to [username][email], whereas desktop will display as [domain][username].