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
Optimusprime_25
Resolver I
Resolver I

Dynamic RLS based on many to many relationships. between two tables

Hello All,

 

We have two tables in the report.

One is report table which contains data, multiple columns along with country and unit as columns.

We have another table where we have user access details in this table.

 

We have to join many to many relationships between these two tables on country as well as unit, why because we want country and unit to be restricted based on access provided in the second table.

Optimusprime_25_0-1673941423933.png

Below is the many -to- many relationships between country and unit columns between two tables.

Optimusprime_25_1-1673942124381.png

 

Can anyone please provide me the solution, how to create dynamic RLS whereas one specif user should be able to see only the data for which he/she has access.

 

Thank you.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Optimusprime_25 , Create a combine column

 

Key = [Country] & "-" & [unit]

 

for the direct query, you use combinevalues

 

then you can create RLS using the user 

 

[user_id] = userprincipalname()

 

How to use Row Level Security (RLS): https://youtu.be/NfdIA0uS6Nk

View solution in original post

HiraNegi
Resolver II
Resolver II

Hi @Optimusprime_25 ,

You may follow below steps with sample scenario.

 

1. Main Data with custom column to concat Country and Unit:

HiraNegi_0-1673944424450.png

 

2. User Data with custom column to combine Country and Unit.

HiraNegi_1-1673944477837.png

 

3. Create join between tables on ID field.

HiraNegi_2-1673944522551.png

 

4. Create new role with filter on UserID = userprincipalname()

This will dynamically filter the dataset for the user login mail id.

HiraNegi_3-1673944662454.png

 

5. Verify if the roles are working as expected.

HiraNegi_4-1673944823611.pngHiraNegi_5-1673944843248.png

 

Hope this helps.

 

Regards,

Hira Negi

 

Please don't forget to upvote and Accept as answer if the reply is helpful

 

View solution in original post

5 REPLIES 5
HiraNegi
Resolver II
Resolver II

Hi @Optimusprime_25 ,

You may follow below steps with sample scenario.

 

1. Main Data with custom column to concat Country and Unit:

HiraNegi_0-1673944424450.png

 

2. User Data with custom column to combine Country and Unit.

HiraNegi_1-1673944477837.png

 

3. Create join between tables on ID field.

HiraNegi_2-1673944522551.png

 

4. Create new role with filter on UserID = userprincipalname()

This will dynamically filter the dataset for the user login mail id.

HiraNegi_3-1673944662454.png

 

5. Verify if the roles are working as expected.

HiraNegi_4-1673944823611.pngHiraNegi_5-1673944843248.png

 

Hope this helps.

 

Regards,

Hira Negi

 

Please don't forget to upvote and Accept as answer if the reply is helpful

 

Hi HiraNegi,

 

Hope you are doing well!

I am also facing the same issue but in Power BI report server. And Many to Many relationship is not available in Power BI report server, could you please help me on priority with some solution.

 

Regars

Sartaj

Thanks @HiraNegi , I have implemented your solution and it's working.

amitchandak
Super User
Super User

@Optimusprime_25 , Create a combine column

 

Key = [Country] & "-" & [unit]

 

for the direct query, you use combinevalues

 

then you can create RLS using the user 

 

[user_id] = userprincipalname()

 

How to use Row Level Security (RLS): https://youtu.be/NfdIA0uS6Nk

Thanks @amitchandak ,  I have implemented your solution and it's working.

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.