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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors