<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dynamic RLS with multiple tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3509434#M134652</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="51073" data-lia-user-login="MarkLaf" class="lia-mention lia-mention-user"&gt;MarkLaf&lt;/a&gt;&amp;nbsp; thank you so much for your help with this.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Nov 2023 11:20:50 GMT</pubDate>
    <dc:creator>debenaire</dc:creator>
    <dc:date>2023-11-01T11:20:50Z</dc:date>
    <item>
      <title>Dynamic RLS with multiple tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3507509#M134564</link>
      <description>&lt;P&gt;Hi there. I have a reasonably complicated dynamic RLS which i am trying to resolve through dax. Attached is the schema.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The premise is the Id in the user table is the USERRPINCIPALNAME&lt;/P&gt;&lt;P&gt;The user has a a list of companies they are allowed access to in the USERALLOWED table&lt;/P&gt;&lt;P&gt;These companies have a relevant ID called InstanceId-CRMId that gets passed into a site list and on to the report to limit the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue i am haivng is i do not want to have to use bidirectional relationships&lt;/P&gt;&lt;P&gt;There iaremany to many relationships&lt;/P&gt;&lt;P&gt;Performance is poor&lt;/P&gt;&lt;P&gt;I cannot seem to get the RLS to properly work and the sites table isnt filtering when I add ID = USERPRINCIALNAME() in the user table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone suggest specifc dax for this use case please??? I have looked at some RADACAD posts on this example but can't work it out.&amp;nbsp;Thanks in advance!!&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 15:00:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3507509#M134564</guid>
      <dc:creator>debenaire</dc:creator>
      <dc:date>2023-10-31T15:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic RLS with multiple tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3507825#M134576</link>
      <description>&lt;P&gt;The filter from User will propogate as long as it travels through one --&amp;gt; many relationships from the one side.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you've noted, it doesn't work nicely when traveling from the other direction, many --&amp;gt; one, like UserAllowedCompany (many) --&amp;gt; (one) Company.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get this working&amp;nbsp;&lt;STRONG&gt;without&amp;nbsp;&lt;/STRONG&gt;relying on bidirection filtering, you'll need to define an RLS filter rule on Company. Note that once that is working, it looks like the RLS filter will propogate throughout the rest of your model through one --&amp;gt; many relationships.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like the following should work as the filter on Company:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE( 
  NOT ISEMPTY( UserAllowedCompany ), 
  User[Id] = USERPRINCIPALNAME() 
)&lt;/LI-CODE&gt;&lt;P&gt;Note that, even though you should also have the User[Id] = USERPRINCIPALNAME() filter on User, the RLS filters aren't evaluated in order, so you need to re-incorporate the underlying USERPRINCIPALNAME() filter any time you are defining a new RLS filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are some screenshots with a dummy model similar to yours in case helpful.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 17:01:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3507825#M134576</guid>
      <dc:creator>MarkLaf</dc:creator>
      <dc:date>2023-10-31T17:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic RLS with multiple tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3507914#M134579</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="51073" data-lia-user-login="MarkLaf" class="lia-mention lia-mention-user"&gt;MarkLaf&lt;/a&gt;&amp;nbsp; thank you so much!! My model has many to many from user to UserAlkowedCompany because the id between them is not the user Id but the Licensee-UserRoleId which can be assigned to many users. &amp;nbsp;Does this make a difference as this is not working in my model. Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 17:55:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3507914#M134579</guid>
      <dc:creator>debenaire</dc:creator>
      <dc:date>2023-10-31T17:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic RLS with multiple tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3508130#M134589</link>
      <description>&lt;P&gt;It should still work similar to my solution. Just ensure that the M:M has filtering direction set where User filters UserAllowedCompany.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That said, I would recommend changing query to join the User Id onto UserAllowedCompany and then setting up a 1:M relationship between User and UserAllowedCompany as set up in the dummy model I showed.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If updating the query isn't possible or desireable, I can update my original post to include a M:M relationship between User and UserAllowedCompany. Just let me know&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 20:04:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3508130#M134589</guid>
      <dc:creator>MarkLaf</dc:creator>
      <dc:date>2023-10-31T20:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic RLS with multiple tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3508177#M134593</link>
      <description>&lt;P&gt;&lt;EM&gt;Actually, I had some time now. Here is original post, tweaked for User : UserAllowedCompany to have M:M relationship.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The filter from User will propogate as long as it travels through a single direction filter. So, either one --&amp;gt; many relationships from the one side OR single filter direction many --&amp;gt; many relationship from the left (A) side of A filters B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you've noted, it doesn't work nicely when traveling from the other direction, many --&amp;gt; one, like UserAllowedCompany (many) --&amp;gt; (one) Company.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get this working&amp;nbsp;&lt;STRONG&gt;without&amp;nbsp;&lt;/STRONG&gt;relying on bidirection filtering, you'll need to define an RLS filter rule on Company. Note that once that is working, it looks like the RLS filter will propogate throughout the rest of your model by leveraging the filter directions on (the rest showing are one --&amp;gt; many relationships).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like the following should work as the filter on Company:&lt;/P&gt;&lt;PRE&gt;CALCULATE( 
  NOT ISEMPTY( UserAllowedCompany ), 
  User[Id] = USERPRINCIPALNAME() 
)&lt;/PRE&gt;&lt;P&gt;Note that, even though you should also have the User[Id] = USERPRINCIPALNAME() filter on User, the RLS filters aren't evaluated in order, so you need to re-incorporate the underlying USERPRINCIPALNAME() filter any time you are defining a new RLS filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are some screenshots with a dummy model similar to yours in case helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 20:31:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3508177#M134593</guid>
      <dc:creator>MarkLaf</dc:creator>
      <dc:date>2023-10-31T20:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic RLS with multiple tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3509434#M134652</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="51073" data-lia-user-login="MarkLaf" class="lia-mention lia-mention-user"&gt;MarkLaf&lt;/a&gt;&amp;nbsp; thank you so much for your help with this.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 11:20:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-RLS-with-multiple-tables/m-p/3509434#M134652</guid>
      <dc:creator>debenaire</dc:creator>
      <dc:date>2023-11-01T11:20:50Z</dc:date>
    </item>
  </channel>
</rss>

