Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Return full username

I have a table that has the username, name among other information, I want to get the username from the pbi and cross it with this table and return the other information of this user

 

I want to cross Username with Login_AD and return First_Name_AD

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous 

    As I mentioned before, UserName() will return Domain\Name in Power BI Desktop. UserPrincipalName() will return email format like [email protected] in Power BI Desktop.

    Both of UserName() and UserPrincipalName() will return email format to show UPN(Current user login in Power BI Service) in Power BI Service. 

    My Test:

    CurrentName = CALCULATE(MAX('Table'[Name]),FILTER('Table','Table'[Domain\Name] = [CurrentUser]))

    In Desktop, UserName() will return Domain\Name, so measure works well.

    In Service, UserName() will return a email format and measure won't work.

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

7 Replies

  • please provide more details. What have you tried and where are you stuck?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Get the usurname from the powerbi session and look it up in the table user and return the name.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    I think you can use Row-Level-Security to restrict data access for given users. Your end user could only see values belong to them after you set RLS in Power BI. What does [Username] looks like, only name or email format? We will use UserName() or UserPrincipalName() Function to get Login_AD. 

     

    UserName() will return Domain\Name in Power BI Desktop. UserPrincipalName() will return email format like [email protected]. Both of them will return email format in Power BI Service. So here I suggest you to use UserPrincipalName(). And you need a Email format column in your table.

     

    My Sample:

    Manage role in Desktop:

    Test Result:

    You need to add the user in Role in Security in Dataset after you publish this report to Power BI Service.

    For reference:

    Manage security on your model

    Note: Workspace members assigned AdminMember, or Contributor have edit permission for the dataset and, therefore, RLS doesn’t apply to them.

    Here is a blog about dynamic RLS in power bi.

    Dynamic Row Level Security with Power BI Made Simple Posted on July 4, 2016

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous I understand your example, but I believe I have not been clear on my problem, what I need is to take the username function that returns the pbi user in domain\user format and look for that user in another table and return the full name.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous 

        As I mentioned before, UserName() will return Domain\Name in Power BI Desktop. UserPrincipalName() will return email format like [email protected] in Power BI Desktop.

        Both of UserName() and UserPrincipalName() will return email format to show UPN(Current user login in Power BI Service) in Power BI Service. 

        My Test:

        CurrentName = CALCULATE(MAX('Table'[Name]),FILTER('Table','Table'[Domain\Name] = [CurrentUser]))

        In Desktop, UserName() will return Domain\Name, so measure works well.

        In Service, UserName() will return a email format and measure won't work.

        Best Regards,
        Rico Zhou

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.