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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mohit_K
Helper I
Helper I

Row level security from two tables.

I have a data table as shown below.

Territory ID

Value

SKU ID

1

20

22

1

30

23

1

40

22

2

50

23

2

60

22

2

70

23

I have two other tables one for Territory ID mapping and the other for SKU ID mapping.

Territory ID

Email Id

1

S@gmail.com

2

A@gmail.com 

 

SKU

Email

22

Mk@gmail.com

23

A@gmail.com

 

I Want to apply Row Level Security such that the rows in the data table are filtered according to the logged-in user and they are able to view only the SKU and Territory assigned to them.

Desired Output:

 

 

For 

S@gmail.com

 

Territory ID

Value

SKU ID

1

20

22

1

30

23

1

40

22

 

 

 

For

Mk@gmail.com

 

1

20

22

1

40

22

2

60

22

 

 

 

For 

A@gmail.com

 

2

70

23

how should I go about creating Row-level Security on these two independent tables?

 

4 REPLIES 4
mohit_K
Helper I
Helper I

@v-jingzhang  Can you please help with this? It's very urgent for us

Hi @mohit_K 

Sorry for the late reply. Please download the attachment for details.

Filters:

VAR skuEmails = VALUES ( 'SKUTable'[Email] )
VAR loginUser = USERPRINCIPALNAME ()
RETURN
    IF ( loginUser IN skuEmails, 'SKUTable'[Email] = loginUser, TRUE () )
VAR territoryEmails = VALUES ( 'TerritoryTable'[Email Id] )
VAR loginUser = USERPRINCIPALNAME ()
RETURN
    IF (
        loginUser IN territoryEmails,
        'TerritoryTable'[Email Id] = loginUser,
        TRUE ()
    )

 

052402.jpg

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

v-jingzhang
Community Support
Community Support

Hi @mohit_K 

 

I create a sample based on your description. You could download the attached pbix file for details.

 

In short, create relationships between TerritoryTable/SKUTable and DataTable based on Territory ID/SKU ID. Then add a filter on the DataTable which refers to the other two tables.

VAR skuEmails = VALUES ( 'SKUTable'[Email] )
VAR territoryEmails = VALUES ( 'TerritoryTable'[Email Id] )
VAR loginUser = USERPRINCIPALNAME ()
RETURN
    IF (
        ( loginUser IN skuEmails )
            && ( loginUser IN territoryEmails ),
        RELATED ( 'TerritoryTable'[Email Id] ) = USERPRINCIPALNAME ()
            && RELATED ( 'SKUTable'[Email] ) = USERPRINCIPALNAME (),
        RELATED ( 'TerritoryTable'[Email Id] ) = USERPRINCIPALNAME ()
            || RELATED ( 'SKUTable'[Email] ) = USERPRINCIPALNAME ()
    )

051301.jpg051302.jpg

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

Hello @v-jingzhang,

The relationship mentioned between the two tables in the question follows a one to many relationship
on the other hand we will be using a many to many relationship for the mapping between the two tables.
I tried creating the filter and the relation sent by you in the previous answer for the many to many relation :-

 

mohit_K_0-1621511329933.png

 

But I am getting the following error when I try to create the filter on the DataTable :-

 

mohit_K_1-1621511515632.png

 

The error message reads :- The column 'TerritoryTable[Email Id]' either doesn't exist or doesn't have a relationship to any table available in the current context. 

Can you please help me with this error?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors