Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

PBI Issue using RLS implemented in Azure SQL DB

Has anyone had any luck implementing RLS in Azure SQL DB and having it work in Power BI reports? I was able to implement and get the desired result set in Azure SQL DB. However, I am not able to get any rows using the same account in PowerBI service\premium using directquery on a basic report using only one table. I cannot see anything in PBI Desktop either, but that is expected since it uses a domain account and Azure SQL DB uses the O365 UID. When I set the security policy below to off then I get all of the rows for the table in Power BI without publishing again. Below is brief description of what I have done.

Setup a Mapper table

  • Create Table[dbo].[Mapper]([User] sysname NULL, CurrentOfficerCode [varchar](255) NULL)
  • Insert into Mapper([User], CurrentOfficerCode) VALUES('Actual office 365 UID', 'Actual officer code')
    • Office 365 UID example: account@domain.net
    • Actual officer code: would be same as account above

 

Create Schema

CREATE SCHEMA Security;

 

Create Function

CREATE FUNCTION Security.fn_ChkSavPredicate(@CurrentOfficerCode as varchar(255))

RETURNS TABLE

WITH SCHEMABINDING

AS

RETURN SELECT 1 AS AccesResult FROM dbo.Mapper

WHERE ([CurrentOfficerCode] = @CurrentOfficerCode AND [User] = USER_NAME());

 

Create Policy

CREATE SECURITY POLICY ChkSavMap

ADD FILTER PREDICATE Security.fn_ChkSavPredicate([CurrentOfficerCode])

ON [dbo].[ChkSav]

WITH (STATE = ON);

 

Validate

Execute AS USER = 'account@domain.net'

Select * from ChkSav

  • When I run this statement, I get the desired result set in Azure SQL DB.

 

0 REPLIES 0

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.