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
soldous
Advocate II
Advocate II

Dynamic slicer based on USERNAME()

Hi to all PBI masters,

 

I have a table with all my data and I need to implement a slicer which would filter the data only to my records based on currently logged user. But I need to use ChicletSlicer with only one chiclet called "Mine". Our model is in SSAS Tabular so my first approach was to create a table with all users, add a column with Mine text in all rows, use the Mine column as a slicer, implement RLS on this table and connect the table to my data table. But in this approach, the data is filtered always with the RLS.

I need to filter the data only with the slicer otherwise to show them all.

 

Could someone help me, please?

Thanks a lot.

1 ACCEPTED SOLUTION

Hi @soldous ,

 

I have the two tables.

v-lionel-msft_0-1598000744430.png

v-lionel-msft_1-1598000760440.png

1. Create such a table visual.

v-lionel-msft_2-1598000824120.png

2. Create such a measure.

__filter = 
IF(
    SELECTEDVALUE('User table'[User]) = USERNAME(),
    1, 0
)

3. Create two buttons.

v-lionel-msft_3-1598000946637.png

4. Create two bookmarks

v-lionel-msft_4-1598000982544.png

5. Add the 'before filtering' bookmark to the 'Back' button and add 'after filtering' bookmark to the 'Mine' button.

 

--After I click ‘Mine’

v-lionel-msft_5-1598001127217.png

 

--After I click "Back"

v-lionel-msft_6-1598001186101.png

 

Best regards,
Lionel Chen

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

3 REPLIES 3
v-lionel-msft
Community Support
Community Support

Hi @soldous ,

 

Lilke this?

--Before filtering

v-lionel-msft_0-1597653394201.png

--After filtering

v-lionel-msft_1-1597653418145.png

v-lionel-msft_0-1597653550215.png

1. Create a user table and create a relationship.

v-lionel-msft_1-1597653620685.png

2. Create a filter measure and add to the table visual.

 

__Filter = 
IF(
    SELECTEDVALUE('User table'[User]) = USERNAME(),
    1,0
)

 

If this is not what you want, please describe the data changes before and after filtering.

In addition, whether you want the slicer to switch options dynamically, the current version(2.84.701.0 64-bit (August 2020)) can not do it.

 

Best regards,
Lionel Chen

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

Thank you for the reply @v-lionel-msft 

 

No, not like this. 

When there is no filter applied I need to show the whole dataset:

Screenshot (149).png

And when the filter is applied I need to show only Projects which belong to the curently logged in user:

Screenshot (150).png

But I need only one button filter for this and the name of the filter must be Mine. 

Now I have a table of all users with the column Mine where is the string like this for each user: "Mine domain/username". This column is the Category in the Chiclet slicer and the slicer is filtere with this measure:

IF(CONTAINS(Dim_User,Dim_User[User_NK],USERNAME()),1,0)

and it works. But you can see three dots in the slicer because there is a longer string with domain/username. 

What I need is to have only "Mine" text in the column for all users and put this column in the slicer but it doesn't work for me.

Hi @soldous ,

 

I have the two tables.

v-lionel-msft_0-1598000744430.png

v-lionel-msft_1-1598000760440.png

1. Create such a table visual.

v-lionel-msft_2-1598000824120.png

2. Create such a measure.

__filter = 
IF(
    SELECTEDVALUE('User table'[User]) = USERNAME(),
    1, 0
)

3. Create two buttons.

v-lionel-msft_3-1598000946637.png

4. Create two bookmarks

v-lionel-msft_4-1598000982544.png

5. Add the 'before filtering' bookmark to the 'Back' button and add 'after filtering' bookmark to the 'Mine' button.

 

--After I click ‘Mine’

v-lionel-msft_5-1598001127217.png

 

--After I click "Back"

v-lionel-msft_6-1598001186101.png

 

Best regards,
Lionel Chen

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

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.

Top Solution Authors
Top Kudoed Authors