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

Using RLS

Hello 

 

In a dasboard, I have few dim tables and fact tables and a Dim.employee table.

From the dim employee table we have the company this person is associated to as well as his email (userprincipal)

 

So suppose that we can add the company field into most of the dim table and fact table, how can we restrict people from company 1 to see the info related to company 1, 2, 3, 4 and peoples from company S to see only the info related to company S. using RLS.

 

How can we do that

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use the following steps to meet your requirement.

 

1. Create a secondary column in dim table.

 

Column = IF([Company] = "Company1"||[Company] = "Company2"||[Company] = "Company3"||[Company] = "Company4",1,0)

 

Using1.jpg

 

2. Create a DAX formula.

 

if(calculate(countrows('Dim'), filter('Dim', 'Dim'[Company] = "Company1" && 'Dim'[Email] = Username())) > 0, [Column] = 0, [Email] = Username())

 

Using2.jpg

 

The result like this,

 

Using3.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

BTW, pbix as attached.       

 

Best regards,

 

Community Support Team _ zhenbw

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

View solution in original post

2 REPLIES 2
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use the following steps to meet your requirement.

 

1. Create a secondary column in dim table.

 

Column = IF([Company] = "Company1"||[Company] = "Company2"||[Company] = "Company3"||[Company] = "Company4",1,0)

 

Using1.jpg

 

2. Create a DAX formula.

 

if(calculate(countrows('Dim'), filter('Dim', 'Dim'[Company] = "Company1" && 'Dim'[Email] = Username())) > 0, [Column] = 0, [Email] = Username())

 

Using2.jpg

 

The result like this,

 

Using3.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

BTW, pbix as attached.       

 

Best regards,

 

Community Support Team _ zhenbw

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

Hi @Anonymous ,

 

take a look at this.

https://radacad.com/dynamic-row-level-security-with-profiles-and-users-in-power-bi

 

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


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.