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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.