Forum Discussion

gisa_sam's avatar
gisa_sam
Frequent Visitor
3 years ago
Solved

RLS - Multiple User Roles with no relationship

Hi,   I have 2 tables, a department table and a user table. Department table is one of the dimensional table connected to the main fact table.While User table is completely different table with no ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  gisa_sam 

    You can refer to the following dax 

    VAR _user_dep =
        CALCULATE (
            MAX ( 'User Table'[User Dep] ),
            'User Table'[User Email] = USERPRINCIPALNAME ()
        )
    RETURN
        SWITCH (
            CALCULATE (
                MAX ( 'User Table'[User Role] ),
                'User Table'[User Email] = USERPRINCIPALNAME ()
            ),
            "Dep_role", IF ( [Department] = _user_dep, TRUE (), FALSE () ),
            "Team_role", IF ( [Team] = _user_dep, TRUE (), FALSE () ),
            "Exec_role", IF ( [Department] IN { "dep1", "dep2" }, TRUE (), FALSE () ),
            "Acc_role", TRUE ()
        )

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.