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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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
Super User
Super User

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
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.