Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

RLS not working with Power BI Service

Hello,

 

I have a sales report and applied RLS security for salespeople to see just their accounts. The sales rep name is mentioned as the full name, for example, Shaikh, Abdulquadir

 

I have tried scalar function USERNAME() and USERPRINCIPALNAME() to display just their records, this works perfectly on desktop but does not work on Power BI service.

 

Also I have granted "Viewer" permission to the user. Does the column name where the name exists should be USERPRINCIPALNAME or USERNAME.

  • Hi Anonymous ,

     

    It should be noted that there is a difference between using the USERNAME() and USERPRINCIPALNAME() functions in Powerbi Desktop and Powerbi Service. In Desktop, the function returns not the UPN of the login account, but the local UPN. When you add a user in Desktop The result returned after the ID is correct, but if the account ID corresponding to the Service is not added in the Powerbi Service, the correct record cannot be displayed. As the above description shows that the result is empty, it illustrates this problem.

     

    Username(),userprincipalname()  return from desktop

     

    Username(),userprincipalname()  return from service

     


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.

    Best Regards,
    Henry

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

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous Thanks, I am already doing this. But when I go to test this it gives me a blank report.

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    It should be noted that there is a difference between using the USERNAME() and USERPRINCIPALNAME() functions in Powerbi Desktop and Powerbi Service. In Desktop, the function returns not the UPN of the login account, but the local UPN. When you add a user in Desktop The result returned after the ID is correct, but if the account ID corresponding to the Service is not added in the Powerbi Service, the correct record cannot be displayed. As the above description shows that the result is empty, it illustrates this problem.

     

    Username(),userprincipalname()  return from desktop

     

    Username(),userprincipalname()  return from service

     


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.

    Best Regards,
    Henry

    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

    Hi Anonymous 

    You are right use USERPRINCIPALNAME() adn it is good that it is working on Desktop.

    On service you have to assign the ID in the Secirity section of the Dataset.

     

    Go to the "Datasets + dataflows" views where your data set it.

    Don't click on the dataset name instead click on the tripple dot.

    and select security and add the IDs to the group they belong to in addition to giving them the viewer priveledge.

     

     

  • pleblanc's avatar
    pleblanc
    Icon for Microsoft Employee rankMicrosoft Employee

    USERPRINCIPALNAME() is what you want to use, but it aligns with the UPN that is used to sign into to Power BI.  For example, if you use [email protected] to sign into Power BI, then that must be store in a table in the model.  Let's say the column name is EmailAddress then the DAX expression on the role would be EmailAddress = USERPRINCIPALNAME().  Check out this video https://youtu.be/MxU_FYSSnYU