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

Dynamic RLS with multiple columns filter

Hello,

 

I need to implement a complex RLS with dynamic column filtering based on email address. I have a fact table containing the columns from the RLS table and the RLS table below:

EmailEntityTarget Segment Survey Type Equipe 
astrid.n@ALLALLALLALL
aliane.b@FranceALLALLALL
martine.t@FranceMerchantGlobal RelationshipALL
ina.s@FranceUserCustomer CareCRC B2C CESU Comearth, CRC B2C Carte Comearth
cedric.m@FranceUserCustomer CareCRC B2C CESU Comearth, CRC B2C Carte Comearth
idrissia.l@FranceClientCustomer CareCRC BtoB MC ERF
lamia.a@FranceMerchant, UserCustomer CareCRC BtoB MC ERF
valeria.z@Italy EB, Italy FMALLALLCRC BtoB MC ERF
david.b@FranceClientCustomer CareCRC BtoB SAV Sitel, CRC BtoB MC Sitel, CRC BtoC Carte Sitel, CRC BtoB MC Sitel Blois, CRC BtoC Carte Sitel Blois
christian.l@FranceUser, MerchantCustomer CareCRC BtoB SAV Sitel, CRC BtoB MC Sitel, CRC BtoC Carte Sitel, CRC BtoB MC Sitel Blois, CRC BtoC Carte Sitel Blois
adrian.p@Italy FMMerchantCustomer CareALL

 

I the end, this table will have approximately 300 email addresses, each with a specific filter, so it needs to be dynamic.

"All" means that needs to have access to all data from that column.

 

1 ACCEPTED SOLUTION

Solution!

I have created some Dim Tabels for every column: Dim_Entity, Dim_Target Segment , Dim_Survey Type, Dim_Equipe. These table are related to the Fact table.

I also imported the Access table, the one in the original post. This one is not related to the fact.

In the modeling I have created a Role filtered for every Dim_Table with the folowing code:

VAR _Restriction =
CALCULATETABLE(
VALUES(Access[Entity]  ------This will be changed with the column from every Dim_Table---------),
Access[Email]=USERPRINCIPALNAME()
)
VAR _RLS_Restriction =
SWITCH(
TRUE(),
OR(
"ALL" IN _Restriction,
[Entity] (------This will be changed with the column from every Dim_Table---------) IN _Restriction),
TRUE(),
FALSE()
)
RETURN
_RLS_Restriction

View solution in original post

3 REPLIES 3

Solution!

I have created some Dim Tabels for every column: Dim_Entity, Dim_Target Segment , Dim_Survey Type, Dim_Equipe. These table are related to the Fact table.

I also imported the Access table, the one in the original post. This one is not related to the fact.

In the modeling I have created a Role filtered for every Dim_Table with the folowing code:

VAR _Restriction =
CALCULATETABLE(
VALUES(Access[Entity]  ------This will be changed with the column from every Dim_Table---------),
Access[Email]=USERPRINCIPALNAME()
)
VAR _RLS_Restriction =
SWITCH(
TRUE(),
OR(
"ALL" IN _Restriction,
[Entity] (------This will be changed with the column from every Dim_Table---------) IN _Restriction),
TRUE(),
FALSE()
)
RETURN
_RLS_Restriction

v-jiewu-msft
Community Support
Community Support

Hi @adrianPadurariu ,

Based on the description, create the relationship between two tables.

Then, try using the following formula to filter.

[Email] = USERPRINCIPALNAME() &&
(
    [Entity] = "ALL" || [Entity] = RELATED('FactTable'[Entity])
) &&
(
    [Target Segment] = "ALL" || [Target Segment] = RELATED('FactTable'[Target Segment])
) &&
(
    [Survey Type] = "ALL" || [Survey Type] = RELATED('FactTable'[Survey Type])
) &&
(
    [Equipe] = "ALL" || [Equipe] = RELATED('FactTable'[Equipe])
)

You can also view the following documents to learn more information.

Configure row-level security with the dynamic method - Training | Microsoft Learn

Solved: RLS multiple combination - Microsoft Fabric Community

Row-level security (RLS) with Power BI - Microsoft Fabric | Microsoft Learn

 

Best Regards,

Wisdom Wu

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

Thank you @v-jiewu-msft I forgot to mention that in my fact table I don't have the Email column so I am not sure how I can connect the two tables.  Based on your description do I need to make multiple inactive relationships for every column?

Where I have "All," there will be blank cells. I wrote "All" just for better understanding.

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!

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.