Forum Discussion

rohitb24's avatar
rohitb24
New Member
11 months ago
Solved

RLS in Power BI report with Direct Query to Azure SQL Database

I have the below table in Az SQL database :

 

Employee table

EmployeeId, FullName, EmailId,""""""""""

 

And I am accessing the above table from the Az SQL database in the report via direct query.

 

The users have full read access on the database on the entire table.

 

And I have created a role in the Power Bi report as below :

 

 

But still the user is able to see all the data.

 

Is it because he/she has full read access on the database?

Then how should RLS be implemented on the report with direct query to the Az SQL Database

  • Hi rohitb24 ,

     

    Thank you for sharing this. 

    It’s not because the user has read access on the database — RLS is still applied when queries flow through Power BI, provided you publish the dataset and assign users to the role in Power BI Service.

     

    Steps to follow

    • Ensure your DAX filter uses USERPRINCIPALNAME() or a similar mapping column.

    • After publishing, assign users to that role under dataset Security in Power BI Service.

    • Test using “View as role” or “Test as role” in the service.

    That way, RLS will work even in DirectQuery mode.

     

    Hope this clears it up 🙌. If this helps, please give a Kudos 👍 and mark as Accepted Solution .

    Thanks
    Shashi Paul 

5 Replies

  • shashiPaul1570_'s avatar
    shashiPaul1570_
    Responsive Resident

    Hi rohitb24 ,

     

    Thank you for sharing this. 

    It’s not because the user has read access on the database — RLS is still applied when queries flow through Power BI, provided you publish the dataset and assign users to the role in Power BI Service.

     

    Steps to follow

    • Ensure your DAX filter uses USERPRINCIPALNAME() or a similar mapping column.

    • After publishing, assign users to that role under dataset Security in Power BI Service.

    • Test using “View as role” or “Test as role” in the service.

    That way, RLS will work even in DirectQuery mode.

     

    Hope this clears it up 🙌. If this helps, please give a Kudos 👍 and mark as Accepted Solution .

    Thanks
    Shashi Paul 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi rohitb24 ,

    Thank you for reaching out to the Microsoft fabric community forum. and also appreciate the helpful answer already provided by shashiPaul1570_ .


    From your screenshot, I can see you have correctly created the RLS role in Power BI Desktop using [EmailId] = USERPRINCIPALNAME(). The next step is to publish the dataset to the Power BI Service and assign the intended users or security groups to that role under Dataset > Security.

    RLS is only enforced when users consume the report through the Service, so while you can test locally with “View as role,” it will not take effect for others until published. Also note that RLS does not apply to workspace Admins, Members, or Contributors, so the users should be assigned the Viewer role for the filtering to work as expected.


    If users connect directly to Azure SQL outside of Power BI, they will still see all data, which is expected behavior. For detailed guidance, More details can be found here: Row-level security (RLS) with Power BI - Microsoft Fabric | Microsoft Learn

    Hope this helps, please feel free to rech out for any further questions.

     

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi rohitb24 ,

     

    I wanted to follow up on our previous suggestions. We would like to hear back from you to ensure we can assist you further.

     

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi rohitb24,

     

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. 


    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi rohitb24 ,

     

    We haven’t received an update from you in some time. Could you please let us know if the issue has been resolved?
    If you still require support, please let us know, we are happy to assist you.

     

    Thank you.