Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Set username as default value in a slicer dynamically based on value selected on other slicer

Hello,

 

The slicer has 2 values "Me" and "All users in my branch". If "Me" is selected, filter the table where the "CreatedBy" column has my username else display all. My data source is SQL server and the username is calculated from the table. Measure created for username is: 

Me = CALCULATE (  MAX ( ACCESS_FW[USER_NAME_FW] ), FILTER ( ACCESS_FW, ACCESS_FW[EMAIL_FW] = USERPRINCIPALNAME()) )

I'm having trouble as UserprincipalName func cannot be used in calculated columns. And measure cannot be added as field to the slicer. And I'm quite not sure if RLS can be used based on "Me" slicer value selection

 

your assistance is much appreciated 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi  Anonymous ,

     

    Here are the steps you can follow:

    1. Create measure.

    Flag =
    var _select=
    SELECTEDVALUE('Slicer Table'[Slicer])
    return
    SWITCH(
        TRUE(),
        _select="Me"&&MAX('ACCESS_FW'[EMAIL_FW])=USERPRINCIPALNAME(),1,
        ISFILTERED('Slicer Table'[Slicer])&&_select<>"Me",1,0
    )

    2. Place [Flag]in Filters, set is=1, apply filter.

    3. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

     

    Here are the steps you can follow:

    1. Create measure.

    Flag =
    var _select=
    SELECTEDVALUE('Slicer Table'[Slicer])
    return
    SWITCH(
        TRUE(),
        _select="Me"&&MAX('ACCESS_FW'[EMAIL_FW])=USERPRINCIPALNAME(),1,
        ISFILTERED('Slicer Table'[Slicer])&&_select<>"Me",1,0
    )

    2. Place [Flag]in Filters, set is=1, apply filter.

    3. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much for the detailed explanation. That worked!

       

      Also, Is it possible to set default value to the slicer based on User login. I have a measure with values "User" and "Manager" depicting the role of the logged in person. When a Manager opens the report the slicer should select "All users in my branch" and when a regular user logs in, the slicer should be selected to "Me". They can change the selection if they want to. 

       

      Though I used bookmarks, it defaults to selection made when I published the report. Can you please help me with that?