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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
adrianPadurariu
Resolver I
Resolver I

Dynamic RLS based on multiple columns and many to many relationship

Hello,

 

I am trying to create a dynamic RLS, but the problem is that my model is a many to many relationship between users table and mapping table and I am not able to create an active relationship  with Security filter aplied. 

This is the model:

adrianPadurariu_0-1732695123828.png

Here is a sample of data from the model

1. Fact

dataset_entitydataset_path
EBEsilver/semarchy/merchants/acceptorReferential
EBEsilver/sun/finance/ledgerAccount
EBGsilver/tri2/merchant/invoiceBulletin
EBGsilver/tri2/merchant/merchantData
ECZsilver/tri/operation/tVrfVoucherRedemptionForm
ECZsilver/tri/sales/tCusCustomer
EDEsilver/sharepointFiles/marketing/salesforceProducts
EDEsilver/sharepointFiles/operation/brandLookup
EDEsilver/sharepointFiles/operation/cmoCardDetails
EFIsilver/delicard/marketing/cards
EFIsilver/delicard/marketing/customers

 

2. Mapping

dataset_entityCountryBL
EBEBelgiumBenefits
EBGUNKNOWN 
ECZCzech RepublicBenefits
EDEGermanyMobility
EFIFinland

Benefits

 

And this is my Users table (exel file in the sharepoint, can be edited anytime by the owner) this will be linked to mapping table:

UserCountryBL
a.b@aaa.comBelgiumBenefits
b.c@aaa.comBelgiumMobility
d.e@aaa.comGermanyMobility
e.f@aaa.comGermanyMobility
g.h@aaa.comFinlandBenefits
h.i@aaa.comFinlandMobility
j.k@aaa.comCzech RepublicAll
l.m@aaa.comAllBenefits

 

So I need to create a dynamic RLS because users can be added or changed in a specific country and to give access to Country and BL

 

Thank you!

 

1 ACCEPTED SOLUTION
adrianPadurariu
Resolver I
Resolver I

SOLUTION!

 

VAR _UserEmail = USERPRINCIPALNAME()
VAR _UserBL =
    CALCULATETABLE(
        VALUES(Users_files_from_sharepoint[BL]),
        FILTER(Users_files_from_sharepoint, Users_files_from_sharepoint[User email] = _UserEmail)
    )
VAR _UserCountry =
    CALCULATETABLE(
        VALUES(Users_files_from_sharepoint[Country]),
        FILTER(Users_files_from_sharepoint, Users_files_from_sharepoint[User email] = _UserEmail)
    )

RETURN

    (CONTAINS(_UserBL, Users_files_from_sharepoint[BL], "eQ") &&
     CONTAINS(_UserCountry, Users_files_from_sharepoint[Country], "eQ"))
    ||
    (CONTAINS(_UserBL, Users_files_from_sharepoint[BL], "All") &&
     CostMonitoring_Mapping_files_from_sharepoint[Country] IN _UserCountry)
    ||
    (CONTAINS(_UserCountry, Users_files_from_sharepoint[Country], "All") &&
     CostMonitoring_Mapping_files_from_sharepoint[BL] IN _UserBL)
    ||
    (NOT CONTAINS(_UserBL, Users_files_from_sharepoint[BL], "All") &&
     NOT CONTAINS(_UserCountry, Users_files_from_sharepoint[Country], "All") &&
     CostMonitoring_Mapping_files_from_sharepoint[BL] IN _UserBL &&
     CostMonitoring_Mapping_files_from_sharepoint[Country] IN _UserCountry)

View solution in original post

3 REPLIES 3
adrianPadurariu
Resolver I
Resolver I

SOLUTION!

 

VAR _UserEmail = USERPRINCIPALNAME()
VAR _UserBL =
    CALCULATETABLE(
        VALUES(Users_files_from_sharepoint[BL]),
        FILTER(Users_files_from_sharepoint, Users_files_from_sharepoint[User email] = _UserEmail)
    )
VAR _UserCountry =
    CALCULATETABLE(
        VALUES(Users_files_from_sharepoint[Country]),
        FILTER(Users_files_from_sharepoint, Users_files_from_sharepoint[User email] = _UserEmail)
    )

RETURN

    (CONTAINS(_UserBL, Users_files_from_sharepoint[BL], "eQ") &&
     CONTAINS(_UserCountry, Users_files_from_sharepoint[Country], "eQ"))
    ||
    (CONTAINS(_UserBL, Users_files_from_sharepoint[BL], "All") &&
     CostMonitoring_Mapping_files_from_sharepoint[Country] IN _UserCountry)
    ||
    (CONTAINS(_UserCountry, Users_files_from_sharepoint[Country], "All") &&
     CostMonitoring_Mapping_files_from_sharepoint[BL] IN _UserBL)
    ||
    (NOT CONTAINS(_UserBL, Users_files_from_sharepoint[BL], "All") &&
     NOT CONTAINS(_UserCountry, Users_files_from_sharepoint[Country], "All") &&
     CostMonitoring_Mapping_files_from_sharepoint[BL] IN _UserBL &&
     CostMonitoring_Mapping_files_from_sharepoint[Country] IN _UserCountry)
johnt75
Super User
Super User

Create new columns on your mapping table and user table, e.g.

Combined Columns =
COMBINEVALUES ( "|", Mapping[Country], Mapping[BL] )

and then use the new columns to create a many-to-many relationship, single direction so that users filters mapping.

Thank you! but what about the situations where I have a user that needs to see the Country and all BL, or a user who needs to see a BL for every Countries?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors