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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

I want to create a slicer with the below values based on the user login details

Hi Experts,

I want to create a slicer with the below values based on the user login details
You and Others.

2 ACCEPTED SOLUTIONS
Selva-Salimi
Super User
Super User

hi @Anonymous 

 

you can create a table as follows : 

 

SelvaSalimi_0-1733225278190.png

 and add "you" and "others" in a column of ths table as follows:

SelvaSalimi_1-1733225332172.png

and use this as a slicer in your report. then you should add a measure like the following in your visuals level filter pane or page level filter pane and set it to 1.

 

FilteredData =
IF(
    SELECTEDVALUE('you_other_table'[Column1]) = "You" && MAX('your_table'[username]) = USERPRINCIPALNAME(),
    1,
    IF(
        SELECTEDVALUE('you_other_table'[Column1]) = "Others" && MAX('your_table'[username]) <> USERPRINCIPALNAME(),
        1,
        0
    )
)
 
and 
SelvaSalimi_2-1733225517723.png

 

 

If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution to help the other members find it more quickly.

View solution in original post

You will need USERPRINCIPALNAME() when creating a RLS role but the user emails must exist in your data.  For example, rows 1-10 are for user01@domain.com while rows 2-20 are for user02@domain.com

Without this information, there's no way you can use USERPRINCIPALNAME() for RLS. Again, your data must indicate which records belong to whom.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

10 REPLIES 10
Selva-Salimi
Super User
Super User

hi @Anonymous 

 

you can create a table as follows : 

 

SelvaSalimi_0-1733225278190.png

 and add "you" and "others" in a column of ths table as follows:

SelvaSalimi_1-1733225332172.png

and use this as a slicer in your report. then you should add a measure like the following in your visuals level filter pane or page level filter pane and set it to 1.

 

FilteredData =
IF(
    SELECTEDVALUE('you_other_table'[Column1]) = "You" && MAX('your_table'[username]) = USERPRINCIPALNAME(),
    1,
    IF(
        SELECTEDVALUE('you_other_table'[Column1]) = "Others" && MAX('your_table'[username]) <> USERPRINCIPALNAME(),
        1,
        0
    )
)
 
and 
SelvaSalimi_2-1733225517723.png

 

 

If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @Selva-Salimi, but this approach will restrict the data, correct? Instead, I want the user to be able to choose using filter options directly on the dashboard.

@Anonymous , no that does not restrict the data, user can choose to see his/her data by choosing you and others by choosing others in the slicer.

 

please share more details of your issue as you use my solution

Ritaf1983
Super User
Super User

Hi @Anonymous 

To achieve this, you can use a method similar to Row-Level Security (RLS) by creating a calculated column or measure that dynamically determines whether a record belongs to the currently logged-in user or to others. Here's how you can do it:

Steps:
Use the USERNAME() or USERPRINCIPALNAME() Function: These DAX functions return the currently logged-in user's username or email. For example:

USERNAME() returns the username in the format DOMAIN\User.
USERPRINCIPALNAME() returns the email address or UPN of the user (preferred for cloud-based models).
Create a Calculated Column: In the dataset where the user information is stored, create a calculated column like this:

DAX
Copy code
UserGroup =
IF(
Table[LoginEmail] = USERPRINCIPALNAME(),
"You",
"Others"
)
Replace Table[LoginEmail] with the column that contains the user email or login details.
Use the Column in a Slicer: Add the UserGroup column to a slicer in your report. The slicer will show two options: "You" and "Others."

Optional: Use a Measure Instead: If you prefer not to create a calculated column, you can achieve this with a measure. For example:

DAX
Copy code
UserGroupMeasure =
IF(
MAX(Table[LoginEmail]) = USERPRINCIPALNAME(),
"You",
"Others"
)
Then, you can use this measure in a visual or as part of your filters.

Limitations:

This approach works best in scenarios where the dataset includes a column with user-specific information (e.g., emails).
If you want to enforce access restrictions, you'll need to configure RLS in addition to this slicer.

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Anonymous
Not applicable

@Ritaf1983  we cant use USERPRINCIPALNAME() in calculated columns in Power BI.

You will need USERPRINCIPALNAME() when creating a RLS role but the user emails must exist in your data.  For example, rows 1-10 are for user01@domain.com while rows 2-20 are for user02@domain.com

Without this information, there's no way you can use USERPRINCIPALNAME() for RLS. Again, your data must indicate which records belong to whom.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
grazitti_sapna
Super User
Super User

Hi @Anonymous ,

you can achieve the desired Output using a calculated column.
Here's how:

Steps to Create the Slicer:

  1. Add a User Column in Your Data
    Make sure your dataset has a column that identifies which rows belong to a specific user. For example, a column named UserEmail in your data should have the email addresses associated with each record.
  2. Create a Calculated Column for the Slicer Values
    Add a calculated column in your dataset that assigns "You" or "Others" based on the current user login. Use the DAX function USERPRINCIPALNAME() to identify the logged-in user.
    SlicerValue =
    IF(
    [UserEmail] = USERPRINCIPALNAME(),
    "You",
    "Others"
    )

    • USERPRINCIPALNAME() returns the email address of the currently logged-in user.
    • The column will dynamically show "You" for rows belonging to the logged-in user and "Others" for the rest.
  3. Create the Slicer Visual
    • Add a slicer to your report.
    • Use the new SlicerValue column as the field for the slicer.
    • The slicer will display "You" and "Others."

Final Output
When a user logs in, they will see "You" for their data and "Others" for other users' data in the slicer.
The slicer allows them to toggle between viewing their data or others' data.

If you want to restrict data visibility based on the logged-in user Please let me know we can Implement that also

I hope the provided solution works for you

If I have resolved your question, please consider marking my post as a solution. Thank you!
A kudos is always appreciated—it helps acknowledge the effort and keeps the community thriving.

Anonymous
Not applicable

@grazitti_sapna , we cant use USERPRINCIPALNAME() in calculated columns in Power BI.

Hi @Anonymous ,

You're absolutely correct! USERPRINCIPALNAME() cannot be used in calculated columns because calculated columns are computed during data refresh and are static. This means they do not respond dynamically to the logged-in user.

Instead of creating a Calculated Column we should Create Measure : Use a measure to dynamically evaluate whether the current row is for the logged-in user.

DAX
SlicerValue =
IF(
SELECTEDVALUE(YourTable[UserEmail]) = USERPRINCIPALNAME(),
"You",
"Others"
)

Use the Measure in a Visual:

  • Add a slicer visual.
  • Set the slicer field to "You" or "Others" using the Measure to display user-specific data dynamically.

This way, slicer adapts to the logged-in user, without requiring RLS or calculated columns.

I hope the provided solution works for you

If I have resolved your question, please consider marking my post as a solution. Thank you!
A kudos is always appreciated—it helps acknowledge the effort and keeps the community thriving.

In this context, it is simply because Power BI doesnt' allow USERPRINCIPALNAME to be used in a calculated column. An attempt to do so will throw an error.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors