Forum Discussion
Need help setting up Role using USERPRINCIPALNAME() with an extra parameter
- 2 years ago
Thanks Pierrev31
Yes that clarifies it!
Here is how I would write the RLS filter expression assuming the table is named Engagements:
VAR UPN = USERPRINCIPALNAME () RETURN CALCULATE ( NOT ISEMPTY ( Engagements ), Engagements[Lead Eng Partner Email] = UPN || Engagements[Eng Partner Email] = UPN || Engagements[Associate Partner Email] = UPN, ALLEXCEPT ( Engagements, Engagements[Lead Engagement] ) )We only need to check the 2nd condition since it dominates the 1st condition. That is, if the current user exists on at least one row with the current row's Lead Engagement, then that user exists on the current row.
Mock-up PBIX attached.
Regards
Thanks Pierrev31
Yes that clarifies it!
Here is how I would write the RLS filter expression assuming the table is named Engagements:
VAR UPN =
USERPRINCIPALNAME ()
RETURN
CALCULATE (
NOT ISEMPTY ( Engagements ),
Engagements[Lead Eng Partner Email] = UPN
|| Engagements[Eng Partner Email] = UPN
|| Engagements[Associate Partner Email] = UPN,
ALLEXCEPT ( Engagements, Engagements[Lead Engagement] )
)
We only need to check the 2nd condition since it dominates the 1st condition. That is, if the current user exists on at least one row with the current row's Lead Engagement, then that user exists on the current row.
Mock-up PBIX attached.
Regards
Hello! I think it worked! I'm testing right now, but so far it's perfect! If possible, could you explain how the ALLEXCEPT function worked here to do this? It would be great in case I face a similar problem in the future. Thank you very much!