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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.