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

Dynamic Row Level Security-to show all country for few users otherwise respective country for others

Hello Everyone,

 

I want to show all country data for few users using dynamic row level security otherwise few user have access to few countries or some have visibility to single country, which country they belong to. Those users who need to access all countries have "All" value in country name in user table. Can someone help me, how to show full data for Amit, and Priyank user and limited data for other users as per their countries.

I've three tables, Users, Country and Sales.

 

User table:

NameEmailCountry
Prateekprateek@abc.comIndia
Prateekprateek@abc.comThailand
Amitamit@abc.comAll
Vickyvicky@abc.comChina
Vickyvicky@abc.comThailand
Priyankpriyank@abc.comAll

 

Country Table:

Country
India
China
Thailand

 

Sales Table:

ProductSalesCountry
A1000India
B2000China
C2500Thailand
D3000India
E500China

 

Can someone provide me the best approach to solve this scenario??

 

Thanks in advance.

1 ACCEPTED SOLUTION
negi007
Community Champion
Community Champion

@Anonymous  Hi Prateek, you will have to do some changes in your user table. I suggest you to have your table in below format. Create a seperate column for user who can have access to full data.

 

negi007_0-1619878340655.png

 

you will then need to create a relatioship like below

 

negi007_1-1619878415879.png

 

then two roles, like below

1st for regional role

negi007_2-1619878474799.png

2nd for all india role

negi007_3-1619878503507.png

then you can do the testing like below

 

negi007_4-1619878587409.png

 

negi007_5-1619878628968.png

 

I am also attaching pbix file for your reference.




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

View solution in original post

9 REPLIES 9
HGINEV
Frequent Visitor

Hello,


I have a similar problem. I have countries France, Germany and UK. I want to set roles for users from respective country (e.g. Role to be like this [Country] == "France") and people who are from France to see only France data. 

However I want the same France users to see some reports which are related to data for the three countries.

 

For example we have 1 report which shows a card with measure count(sales_id) =>for France they are 100. But on the second card report I have count(sales_id),RemoveFilters(Sales[Country]) =>here we see the sales for all countries which are 300. When I apply the RLS for France, automatically the second report displays 100 instead of 300.

 

Thank you in advance for your help!

negi007
Community Champion
Community Champion

@Anonymous Yes, since RLS is filtering data from your master user table, if it does not find any matching value then no data will be visiable. I am happy that I was able to solve your problem. RLS can sometime be difficult to implement as well. Cheers!!!




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Anonymous
Not applicable

Hi @negi007 

 

I got another issue in RLS. After applying these 2 roles as suggested by you, I published the report. Then I added one user in Region Role for test purpose but when I click on 'test as role' for this role, it shows blank data for users.

Then I try for Top role and the output is same.

 

It is showing no data for both roles. In Power BI Desktop, it is working properly for both roles but after publishing in Power BI Service it's not working. Could you please help?

 

Thanks in advance.

@Anonymous After implementing RLS in your dataset in powerbi desktop, you have to add RLS in powerbi services as well. You will have to add all IDs in the role. For example, let say you have a region role, then add all ids who will have region access and same way add ids in the other roles.




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Anonymous
Not applicable

Hi @negi007 

 

I added those ids in Power BI Service under RLS but it is not showing data for users.

@Anonymous can you pl. share your powerbi file if possible you can keep non-sensitive data.




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Anonymous
Not applicable

Hi @negi007 

 

It is having confidential data and also in client space. So can't send you but I replicated the same Dax expressions in roles and created table as per your suggestion.

Even for userprincipalname() Dax function for region, its not showing data for same users in Power BI Service 

negi007
Community Champion
Community Champion

@Anonymous  Hi Prateek, you will have to do some changes in your user table. I suggest you to have your table in below format. Create a seperate column for user who can have access to full data.

 

negi007_0-1619878340655.png

 

you will then need to create a relatioship like below

 

negi007_1-1619878415879.png

 

then two roles, like below

1st for regional role

negi007_2-1619878474799.png

2nd for all india role

negi007_3-1619878503507.png

then you can do the testing like below

 

negi007_4-1619878587409.png

 

negi007_5-1619878628968.png

 

I am also attaching pbix file for your reference.




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Anonymous
Not applicable

Thanks @negi007. It helped me but found one issue, in User table if some country is not avaialable (for eg. if I don't have any user for Thailand country) and it is on Country master table then for Roles on All countries it's showing only those countires which are matching with Coutry master table.

 

Anyways, I've user for all countries so no issues with the solution.

 

Thank you so much!!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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