Forum Discussion

mohit_K's avatar
mohit_K
Helper I
5 years ago

Row Level Security

I have a Data Table as shown below :-

Territory IDValueSKU ID
11122
12223
13322
24423
25522
26623
37724
38824
39922
41225
41326
51425
63224
65424
64527
66727

 

I have two other tables, one for Territory ID mapping and the other for SKU ID mapping.
As shown below :-
Territory Table :-

Territory IDEmail Id
1[email protected]
2[email protected]
3[email protected]
4[email protected]
5[email protected]
6[email protected]
7[email protected]
8[email protected]
1[email protected]
1[email protected]
2[email protected]
3[email protected]
4[email protected]

 

SKU Table :-

SKU IDEmail
22[email protected]
23[email protected]
24[email protected]
25[email protected]
26[email protected]
27[email protected]
22[email protected]
23[email protected]
25[email protected]

 

The Territory and SKU tables are linked to Data Table with a Many to Many Relationship
I want to apply Row Level Security such that the rows in the Data Table are filtered
according to the user logged in and they should be able to view only the Territory or SKU assigned to them.

 

So if user [email protected] logs in them the Output should be :-

Territory IDValueSKU ID
11122
12223
13322
24423
25522
26623
37724
38824
39922
41225
41326


[email protected] only exists in Territory Table hence only filter from that table

 

if user [email protected] logs in them the Output should be :-

Territory IDValueSKU ID
11122
12223
13322
24423
25522
26623
39922
41225
41326
51425

 

[email protected] only exists in SKU Table hence only filter from that table


if user [email protected] logs in, then the Output should be :-

Territory IDValueSKU ID
11122
12223
13322
24423
25522
26623


[email protected] exists in both Territory and SKU Table hence filter from both the tables.


How should I go about creating Row Level Secutrity on these two independent tables?

1 Reply

  • SivaMani's avatar
    SivaMani
    Resident Rockstar

    mohit_K,

     

    Try the below DAX in RLS,

    Table - SKU:

    IF(USERPRINCIPALNAME() IN VALUES(SKU[Email]),[Email]=USERPRINCIPALNAME(),TRUE())

     

    Table - Territory:

    IF(USERPRINCIPALNAME() IN VALUES(Territory[Email Id]),[Email Id] = USERPRINCIPALNAME())