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
stuartta
Regular Visitor

Using USERNAME() as a filter AFTER RLS is applied

Hello,

I am trying to set up a dashboard with multiple views based on a filter that is derived from the USERNAME function.

 

At the moment the data has RLS applied to it so that when someone logs on, it will only show them those people underneath them in the organisation by applying a combination of PATH and PATHCONTAINS, this works well, but I want to add a new column to the table based on the USERNAME() output to allow users to select whether they see everyone below them or just their imediate team.

 

I was trying to set up an additional conditional column that was along the lines of:

 

Filter = IF([Mananger]=Username(),"Team","Organisation")
 
So if the person logged on is the employees direct manager the column contains "team", if they are in their management hierarchy they see "Organisation"
 
That throws up the error message "CUSTOMDATA, USERNAME, USERCULTURE and USERPRINCIPALNAME functions are not supported in calculated tables/columns. These functions may only be used in Measures or in the AllowedRowsExpression."
 
Any idea how I can implement this?
 
Cheers
 
1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

the problem is not really related to RLS. The issue is that the calculated columns/tables are only changing during the refresh. The way you describe it the column would have to change between Team/Organization depending on who is logged in - at the moment PowerBI just doesn't work like this

 

to make it work you would need to have both the Organization and Team versions of the table for relevant users, and then filter with RLS



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

1 REPLY 1
Stachu
Community Champion
Community Champion

the problem is not really related to RLS. The issue is that the calculated columns/tables are only changing during the refresh. The way you describe it the column would have to change between Team/Organization depending on who is logged in - at the moment PowerBI just doesn't work like this

 

to make it work you would need to have both the Organization and Team versions of the table for relevant users, and then filter with RLS



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

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.