Forum Discussion

GimmeDaData's avatar
GimmeDaData
Regular Visitor
3 years ago
Solved

Dynamic RLS / 2 conditions based on 2 columns

Hello,   I need to set up a dynamic RLS. I need users to be able to only see data related to their category, which is easy ("[PrincipalName] = userprincipalname()" filter on permission table and a ...
  • GimmeDaData's avatar
    GimmeDaData
    3 years ago

    Hey,

     

    Thanks for your answer. 

     

    I think I solved it. I brought the Product Manager into the fact table and simply set this RLS filter on that fact table:

     

    VAR user_name =
        LOOKUPVALUE (
            'Permissions Table'[Name],
            'Permissions Table'[Email- (Short Form)], USERPRINCIPALNAME()
        )
    VAR user_categories =
        CALCULATETABLE(
           VALUES ('Permissions Table'[AccessToCategory] ),
           FILTER(
              'Permissions Table',
              'Permissions Table'[Email- (Short Form)] = USERPRINCIPALNAME()
           )
        )
    RETURN
        OR (
            'FactTable'[ProductManager] = user_name,
            'FactTable'[Category] IN user_categories
        )

     

     

    I know it is not necessarily considered a best practice to set a RLS filter on a fact table but it doesn't seem to impact performance as much.

     

    Thanks again for the tip 🙂

     

    Kid regards,

    GimmeDaData