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
Hello!
Yes If he appears at all as a Lead Eng Partner, Eng Partner or Associate Partner for any Engagement, he should be able to see all rows associated with the Lead Engagement of that Engagement. So just to make it clear, I expanded the base to show what I mean:
| Lead Engagement | Engagement | Lead Eng Partner Email | Eng Partner Email | Associate Partner Email | Can see? |
| 2001401234 | 3000431234 | [email protected] | [email protected] | n/a | Yes |
| 2001401234 | 3000401555 | [email protected] | [email protected] | n/a | Yes |
| 2001401234 | 2001401234 | [email protected] | [email protected] | n/a | Yes |
| 2007543543 | 2007543543 | [email protected] | [email protected] | n/a | No |
| 2007543543 | 3001546654 | [email protected] | [email protected] | n/a | No |
| 2005125452 | 2005125452 | [email protected] | [email protected] | [email protected] | Yes |
| 2005125452 | 3005324565 | [email protected] | [email protected] | n/a | Yes |
He is part of the Engagement 3000431234, part of the larger Lead Engagement 2001401234, so he should also be able to the rows for the Eng. 3000401555 and Eng, 2001401234, even though he doesn't show up in any of those email columns for those two Engagements, as they are part of the larger Lead Engagement 2001401234.
Same thing applies to the Lead Eng. 2005125452, as he is an Associate in the Eng. row 2005125452, so he should the entire Lead Eng.
And in the case of the Lead Eng. 2007543543, as he doesn't show up in any rows for the Engs. he shouldn't be able to see it at all.
Thank you very much! Hope I was clear!
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
- Pierrev312 years agoFrequent Visitor
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!