Forum Discussion

gsk135's avatar
gsk135
Regular Visitor
1 year ago
Solved

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. U...
  • SamWiseOwl's avatar
    1 year ago

    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()

    )

    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