Forum Discussion
How to filter table by USERPRINCIPALNAME()
Hi,
I would like to filter data by USERPRINCIPALNAME() via RLS.
For in stance, in below table, when USERPRINCIPALNAME = '[email protected]', it should show first 2 rows, which contains '[email protected]'
I've created a role with a table filter, but it doesn't work. Any suggestions? Thanks
CONTAINS(
[fact_Logon],
[MappingEmail],
USERPRINCIPALNAME()
) = True()
spagad6263 I don't use this new look, I don't like it at all. Switch to the DAX editor and past the code there.
9 Replies
- parry2kSuper User
spagad6263 you need to add a measure:
Measure = VAR __UPN = USERPRINCIPALNAME () RETURN CALCULATE ( COUNTROWS ( Table ), CONTAINSSTRING ( Table[MappedEmail], __UPN ) )- spagad6263Post Patron
This doesn't quite work.
I tried below using roles editor. No syntax error, but not returning what I need. Any thoughts?
USERPRINCIPALNAME() IN fact_Contact[MappingEmailAddress]
- spagad6263Post Patron
Thanks for the reply. I've created below measure. Can you advise how I could link this to the role?
meas_Filter =VAR UPN = USERPRINCIPALNAME ()RETURNCALCULATE (COUNTROWS (fact_Contact),CONTAINSSTRING (fact_Contact[MappingEmailAddress], UPN)) - parry2kSuper User
spagad6263 you should put this in the role instead:
VAR __UPN = USERPRINCIPALNAME () VAR __Table = FILTER ( Table, CONTAINSSTRING ( Table[MappedEmail], __UPN ) ) RETURN NOT ISEMPTY ( __Table ) - spagad6263Post Patron
Unfortunately, there is no CONTAINS option below
- parry2kSuper User
spagad6263 I don't use this new look, I don't like it at all. Switch to the DAX editor and past the code there.
- spagad6263Post Patron
Thank you for the help!
- spagad6263Post Patron
Hi,
Do you think below should work?
FIND(USERPRINCIPALNAME(),fact_Contact[MappingEmailAddress]) > 0
Thanks
- parry2kSuper User
spagad6263 as far as expression returns true/false, it should work.