Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
HariniParthiban
Regular Visitor

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()) )

HariniParthiban_0-1712921013317.png

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 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @HariniParthiban ,

 

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.

vyangliumsft_0-1713151692290.png

3. Result:

vyangliumsft_1-1713151724846.png

vyangliumsft_2-1713151724847.png

 

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

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @HariniParthiban ,

 

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.

vyangliumsft_0-1713151692290.png

3. Result:

vyangliumsft_1-1713151724846.png

vyangliumsft_2-1713151724847.png

 

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

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?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.