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
Rai_BI
Helper III
Helper III

Get the filter applied in RLS and show it in the visual

Hey guys,

I created a dashboard in Power BI with some sales information. In this report I applied RLS security so that users only see information about themselves, that is, they can only see the sales they made so as not to see information from other users. In this dashboard I need to create a dynamic title that brings the user's name respecting the RLS applied, that is, if the user's name is "Jhon M. Stan" the title needs to be "Jhon M. Stan", as the filter applied to the RLS is "John M. Stan".

I tried using a SELECTEDVALUE in the table column where the seller's name is, but that didn't work, as the filter is in RLS and not in a data segmentation.

Please, would anyone know how to do this?

5 REPLIES 5
v-binbinyu-msft
Community Support
Community Support

Hi @Rai_BI ,

In Power BI Desktop, username() and userprincipalname() function will return the domain\user, but in Power BI Service, userprincipalname() function will return the upn name.

I create a sample for you:

1. below is my test data

Table:

vbinbinyumsft_0-1703485233634.png

2. create a role

vbinbinyumsft_1-1703485260840.png

3. create a measure

Measure = USERPRINCIPALNAME()

4. add a table visual with Table fields and set the title text

vbinbinyumsft_2-1703485351468.png

5. result

vbinbinyumsft_4-1703485501047.png

 

vbinbinyumsft_3-1703485406832.png

 

 

 

 

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Fowmy
Super User
Super User

@Rai_BI 

If you could expalin this part of your question?

"I tried using a SELECTEDVALUE in the table column where the seller's name is, but that didn't work, as the filter is in RLS and not in a data segmentation."

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

I meant that the SELECTEDVALUE function does not work if there is no filter in the data slicer. As the filter is applied to RLS, the SELECTEDVALUE function is useless in this case.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly but please try to write a measure like below and put it into the card visualization. And then publish it to the service. 
Each user will see his/her name on the report.

Show user name measure: = USERPRINCIPALNAME()

 

USERPRINCIPALNAME function (DAX) - DAX | Microsoft Learn

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


It's not working as expected. It's bringing the user name like the following example "SERVBUSINESS\USER" and that's not what I'm looking for.

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.