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
adambhappy
Resolver II
Resolver II

Using filter slicer to dynamically apply RLS to achieve a default filter

I'm building a report that will be used by sales people to view sales figures per customer and the report contains the data for all customers within the company. The users are supposed to be able to access the information for all customers but when they initially log in to the report I want it to be filtered on their customer.

 
Below is a screenshot of the filters at the top of the report, the Own customers / All customers filter is a manual table entered into Power BI which is not connected to any of the other tables.

 

PBI_Question_RLS_Dynamically_Slicer.png

 

So I've been playing around with using SELECTEDVALUE on the Customer filter field to use an IF conditional statement in RLS to filter the customer table but I can't seem to get it to work properly. Below is the code I've tried in RLS on the customer table but it doesn't seem to work the they I want it to.

 

IF((USERPRINCIPALNAME()>customers[upn]&&SELECTEDVALUE(filter_table[Customer filter],"All customers")="Own customers"),0,1) = 1


Using SUMX() on the customer table I can get the IF-statement to properly evaluate on row level but I'm thinking that there is something about how/when RLS is computed that means that my approach won't work.

Has anyone done something similar where you've used the selected value in a slicer to apply RLS?

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @adambhappy

"The users are supposed to be able to access the information for all customers but when they initially log in to the report I want it to be filtered on their customer."

 

you mean:

your end users have the permission to see all data,

but when they open the report for first time, they can only see their own data.

meanwhile, on the report, there is a slicer which is selected at "own customer" by default.

to see all data, user can switch "own customer" to "all".

 

Right?

 

Best Regards

Maggie

Yes, that is the scenario I'm trying to achieve. I can create a DAX measure that evaluates to 1 for each customer based on a combination of the two conditions: they own the customer or they have selected to show all customers. However I can't use that as a filter in the slicer where they select the customer.

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