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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
gsk135
Regular Visitor

Override RLS

I have a table which has a region field. I created a table as access with username, region, useradmin. 

 

I want to filter region on main table based on the username and region from access table. Useradmin's should able to see all the regions and should not filter anything. 

 

I tried below roles but it did not work. 

 

[username] = USERPRINCIPALNAME()

if ( [username] = USERPRINCIPALNAME(), true(), [useradmin]=USERPRINCIPALNAME())

1 ACCEPTED SOLUTION
SamWiseOwl
Super User
Super User

Hi @gsk135 

Assign something like as the filter on your security table

SWITCH(
    TRUE()
    ,USERNAME() IN VALUES(Security[User]) //if the username is in the security table
    ,Security[User] = USERNAME() //filter to that user
    ,USERNAME() = "Admin" //if the user is admin return true i.e all data
    ,TRUE()

)

SamWiseOwl_3-1734037555120.pngSamWiseOwl_4-1734037577688.pngSamWiseOwl_5-1734037596165.pngSamWiseOwl_6-1734037612652.png

To test click Modelling | View As then under Other user enter the name to test. Also tick the security role you created here mine is untitled


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

1 REPLY 1
SamWiseOwl
Super User
Super User

Hi @gsk135 

Assign something like as the filter on your security table

SWITCH(
    TRUE()
    ,USERNAME() IN VALUES(Security[User]) //if the username is in the security table
    ,Security[User] = USERNAME() //filter to that user
    ,USERNAME() = "Admin" //if the user is admin return true i.e all data
    ,TRUE()

)

SamWiseOwl_3-1734037555120.pngSamWiseOwl_4-1734037577688.pngSamWiseOwl_5-1734037596165.pngSamWiseOwl_6-1734037612652.png

To test click Modelling | View As then under Other user enter the name to test. Also tick the security role you created here mine is untitled


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

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