Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Shantanu3006
New Member

Implementing RLS in Power BI

Hi All

I am trying to implement the RLS in power BI. What I want to implement is the security at the country and the clients within the country. If a person belongs to a specific country, he should see the data of that country and the clients within the country he is entiltled to see.

Below is the user access table that I have in PBI. I also have country and client column in the fact table.

 

CountryNameEmaild IDClient
USAemailid1ALL
GermanyAemailid1KLM
GermanyAemailid1ABC
USBemaild2PQR
GermanyCemaild3HIJ

 

Here, if a user 'A' logs on the report, he should see the data related to client 'KLM' and 'ABC' for Germany and he should see data of all the clients for the 'US'.

I tried to implement it with the filter on client and country with AND condition. It works with the scenarions where I dont have 'ALL' for clients.

 

Any help for this issue is greatly appreciated. 

 

Thanks

Shantanu

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

Thanks for the reply from AmiraBedh , please allow me to provide another insight: 
Hi  @Shantanu3006 ,

 

Here are the steps you can follow:

1. Modeling – Manage Roles – Filter data -- Place the following formula .

When applying to multiple users, you can replace "A" with USERPRINCIPALNAME().

var _table1=
    FILTER('Table','Table'[Name]="A")
var _Country=
SELECTCOLUMNS(_table1,"Country",[Country])
var _Email=
SELECTCOLUMNS(_table1,"email",[Emaild ID])
RETURN
IF(
    [Emaild ID] in _Email || [Country] in _Country,TRUE(),FALSE())

vyangliumsft_0-1729588476611.png

2. Result:

vyangliumsft_1-1729588476612.png

 

Best Regards,

Liu Yang

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-yangliu-msft
Community Support
Community Support

Thanks for the reply from AmiraBedh , please allow me to provide another insight: 
Hi  @Shantanu3006 ,

 

Here are the steps you can follow:

1. Modeling – Manage Roles – Filter data -- Place the following formula .

When applying to multiple users, you can replace "A" with USERPRINCIPALNAME().

var _table1=
    FILTER('Table','Table'[Name]="A")
var _Country=
SELECTCOLUMNS(_table1,"Country",[Country])
var _Email=
SELECTCOLUMNS(_table1,"email",[Emaild ID])
RETURN
IF(
    [Emaild ID] in _Email || [Country] in _Country,TRUE(),FALSE())

vyangliumsft_0-1729588476611.png

2. Result:

vyangliumsft_1-1729588476612.png

 

Best Regards,

Liu Yang

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

AmiraBedh
Most Valuable Professional
Most Valuable Professional

Why do you have the country and client columns in the fact table if the country already belongs to the client dimension ?

Can you share the design of your data model ?

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.