Forum Discussion

spagad6263's avatar
spagad6263
Post Patron
2 years ago
Solved

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

  • spagad6263 you need to add a measure:

     

    Measure = 
    VAR __UPN = USERPRINCIPALNAME ()
    RETURN
    CALCULATE ( 
       COUNTROWS ( Table ),
       CONTAINSSTRING (  Table[MappedEmail], __UPN )
    )
    • spagad6263's avatar
      spagad6263
      Post 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]

  • 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 ()
    RETURN
    CALCULATE (
       COUNTROWS (fact_Contact),
       CONTAINSSTRING (fact_Contact[MappingEmailAddress], UPN)
    )
  • spagad6263 you should put this in the role instead:

     

    VAR __UPN = USERPRINCIPALNAME ()
    VAR __Table = FILTER ( Table, CONTAINSSTRING (  Table[MappedEmail], __UPN ) )
    RETURN
    NOT ISEMPTY ( __Table )
  • 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.

  • Hi,

     

    Do you think below should work?

     

    FIND(USERPRINCIPALNAME(),fact_Contact[MappingEmailAddress]) > 0

     

    Thanks