Forum Discussion

Tucker's avatar
Tucker
Icon for Helper I rankHelper I
9 years ago
Solved

USERNAME() function DAX

Hey guys, I'm trying to use either =username() or =principleusername() with RLS. My issue is that I have created a dataset as a SQL View and brought this into the desktop, I then created a tbl and ...
  • v-jiascu-msft's avatar
    9 years ago

    Hi Tucker,

     

    According to the official document, the format of user name in Service is UPN, which looks like an email address [email protected]. So,

    1. The list of user names should be UPN, which we can find out the exact format in the Service with function userprincipalname().

    2. We should use userprincipalname() in the role we defined in Desktop.

     

    >>Within the Power BI service, username() and userprincipalname() will both return the user's User Principal Name (UPN). This looks similar to an email address.

     

    My test:

     

    formula of a role:
    IF (
        USERPRINCIPALNAME () = "[email protected]",
        [Column1] < 1000,
        [Column1] = 0
    )

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Best Regards!

    Dale