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
Anonymous
Not applicable

Toggling dynamic row level security

I'm trying to figure out how I can toggle row-level fitering or security for a certain use-case.  My customers are expecting to be able to toggle between seeing:

  • All of the data that their (in)direct reports have access to (All)
  • Only data they have access to, but not their direct reports (Mine)

 

Suppose there is a situation where an organization chart exists along the lines of:

AdamPresident  
 BradVP 
  CharlieManager

 

In a seperate table, suppose cost centers are defined as:

Cost center#Owner
001Adam
002Adam
003Brad
004Brad
005Charlie

 

The user should be able to toggle between these binary options and not have to apply a filter specifying their name, employee number or anything else that isn't a boolean TRUE/FALSE.

 

I've able to each person to see their data and everyone's beneath them, but can't figure out this toggle situation.  Does anyone have a solution for both Adam and Brad being able to toggle between seeing only their own data vs. their entire umbrella's data?  

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I was able to work out a solution by adding another dimensional table and applying RLS against that.

  • I applied bidirectional filtering to the new table, but did not apply security in both directions.
    • This way, with RLS applied to DIM_Cost_Center, I start with only the cost centers that each employee is permitted to see.
    • This table then filters which cost centers are accessible from DIM_Cost_Center_Selection[Selection]="All".
  • The second RLS filter limits which records are visibile in DIM_Cost_Center_Selection[Selection]="Mine"

Now I'm able to throw slicers on the canvas where the end-user specifies DIM_Cost_Center_Selection[Selection] and all visuals (including additional slicers) update accordingly.

 

 
DIM_Cost_Center
   
DIM_Cost_Center_Selection
 
Cost CenterCost Center NameOwnerCost CenterEmail AddressSelection
001ApplesAdam001Adam@Contoso.comAll
002BananasAdam002Adam@Contoso.comAll
003CarrotsBrad003Brad@Contoso.comAll
004DatesBrad004Brad@Contoso.comAll
005EggplantsCharlie005Charlie@Contoso.comAll
   001Adam@Contoso.comMine
╚════════════  ⇔══════002Adam@Contoso.comMine
    003Brad@Contoso.comMine
    004Brad@Contoso.comMine
    005Charlie@Contoso.comMine

RLS:

Filter on Owner using employee org chart

  

RLS:

Or(DIM_Cost_Center_Selection[Email Address]=USERPRINCIPALNAME(), DIM_Cost_Center_Selection[Selection]="All")

 

 

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@Anonymous there are lot of blogs/posts available to handle these or similar scenarios, here is link to one, you should pretty much able to change it to meet your needs.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k ,

 

Perhaps I didn't explain my problem statement as clearly as I thought.  The example you referenced is something I have already solved for, which is using RLS to let "each person see their data and everyone's beneath them."  What it doesn't address is enabling a person to easily hide their subordinate's data with the use of a binary option.

 

Referencing the situation I originally outlined, it was easy for me to use RLS so that:

  • Adam can see data associated with cost centers {001,002,003,004,005},
  • Brad can see {003,004,005}, and
  • Charlie can see {005}.

What I haven't been able to find is being able to use a YES/NO or Mine/All toggle so that:

  • Adam only sees {001,002},
  • Brad only sees {003,004}, and
  • Charlie still sees {005}.

 

Yes, I could have a slicer that lists the names of the employees, but if a leader has 100 people below him/her, then it is no longer convenient for the end user to perform "just show me mine." 

 

While I can write the measures necessary to define the logic for what to hide/show,

  1. Power BI doesn't let me use the same code in a calculated column because it depends on the USERPRINCIPALNAME() function
  2. We can't apply measures to report-level or page-level filters

 

Edit:  Another wrinkle in this situation is that a person can be assigned to multiple RLS roles, so bidirectional filtering is another function that seems to be out-of-the-question....

 

Regards,

Rob

@Anonymous aha, so let me see if I understood if correctly

 

- you already solved where a user can see his own department and employee under him, correct?

 

Problem we need to solve:

 

there is a selection (may be a slicer) to toggle between 

- see his own department only

- see his own and his team department

 

so based on selection you want to show the data, correct?

 

If this is correct understanding, I would request you to send me pbix file (remove any sensitive information) and it can be achieved. We have to do the logic in RLS formula based on selection, not thru filter etc.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

I was able to work out a solution by adding another dimensional table and applying RLS against that.

  • I applied bidirectional filtering to the new table, but did not apply security in both directions.
    • This way, with RLS applied to DIM_Cost_Center, I start with only the cost centers that each employee is permitted to see.
    • This table then filters which cost centers are accessible from DIM_Cost_Center_Selection[Selection]="All".
  • The second RLS filter limits which records are visibile in DIM_Cost_Center_Selection[Selection]="Mine"

Now I'm able to throw slicers on the canvas where the end-user specifies DIM_Cost_Center_Selection[Selection] and all visuals (including additional slicers) update accordingly.

 

 
DIM_Cost_Center
   
DIM_Cost_Center_Selection
 
Cost CenterCost Center NameOwnerCost CenterEmail AddressSelection
001ApplesAdam001Adam@Contoso.comAll
002BananasAdam002Adam@Contoso.comAll
003CarrotsBrad003Brad@Contoso.comAll
004DatesBrad004Brad@Contoso.comAll
005EggplantsCharlie005Charlie@Contoso.comAll
   001Adam@Contoso.comMine
╚════════════  ⇔══════002Adam@Contoso.comMine
    003Brad@Contoso.comMine
    004Brad@Contoso.comMine
    005Charlie@Contoso.comMine

RLS:

Filter on Owner using employee org chart

  

RLS:

Or(DIM_Cost_Center_Selection[Email Address]=USERPRINCIPALNAME(), DIM_Cost_Center_Selection[Selection]="All")

 

 

Anonymous
Not applicable

Thanks so much for this solution, this works perfectly for me!

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.