Forum Discussion
naninamu
3 years agoHelper IV
RLS with conditional tables
Hello - was helping someone could help me as I attempt to implement RLS on a model I've inherited. Simply put, the User is in a table with their ID and another column which specifics which table ...
- Anonymous3 years ago
Hi naninamu ,
Please try to create a role with below dax formula:
[Area] = VAR _id = USERPRINCIPALNAME () VAR a = CALCULATE ( MAX ( 'User'[Table] ), CONTAINSSTRING ( 'User'[ID], _id ) ) VAR b = CALCULATE ( MAX ( 'Table A'[Area] ), CONTAINSSTRING ( 'Table A'[ID], _id ) ) VAR c = CALCULATE ( MAX ( 'Table B'[Area] ), CONTAINSSTRING ( 'Table B'[ID], _id ) ) VAR val = SWITCH ( a, "A", b, "B", c ) RETURN valadd a table visual with Table fields:
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
naninamu
3 years agoHelper IV
Thank you so much for this! I will have a go at implementing it (to the slightly more complicated real life situation) and see how we go.
Cheers, Andrew