<?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: INTERSECT between 2 Tables with different Filter Values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4157565#M165210</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="705343" data-lia-user-login="kfortenberry" class="lia-mention lia-mention-user"&gt;kfortenberry&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can write a measure as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;measure count_policy := var tbl1= summarize( filter (activities, [activity type] = "TF") , activities [client code])&lt;/P&gt;&lt;P&gt;var tbl2 = summarize ( filter (policies sold , policies sold [client code] in tbl1) , policies sold [ client code] , policies sold [ policy number]&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;return countrows (tbl2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If this post helps, then I would appreciate a thumbs up&amp;nbsp;&amp;nbsp;and mark it as the solution&amp;nbsp;to help the other members find it more quickly.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 18 Sep 2024 17:26:58 GMT</pubDate>
    <dc:creator>Selva-Salimi</dc:creator>
    <dc:date>2024-09-18T17:26:58Z</dc:date>
    <item>
      <title>INTERSECT between 2 Tables with different Filter Values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4157530#M165209</link>
      <description>&lt;P&gt;Hi Everyone, I would appreciate any assistance you could provide.&amp;nbsp; I have two tables that share a Many to Many relationship. The first is a record of all activities created by our staff and the second is a list of all policies sold. (The actual tables are considerably larger and contain many more columns.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Activities: need to filter for only TF activities&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Client Code&lt;/TD&gt;&lt;TD&gt;Activity Type&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Client Name&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A123&lt;/TD&gt;&lt;TD&gt;TF&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Adam&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B229&lt;/TD&gt;&lt;TD&gt;TF&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Bob&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C234&lt;/TD&gt;&lt;TD&gt;CT&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Charles&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;E762&lt;/TD&gt;&lt;TD&gt;NO&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;David&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A123&lt;/TD&gt;&lt;TD&gt;TF&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Adam&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B229&lt;/TD&gt;&lt;TD&gt;NO&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Bob&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C234&lt;/TD&gt;&lt;TD&gt;CT&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Charles&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A123&lt;/TD&gt;&lt;TD&gt;CT&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Adam&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;E762&lt;/TD&gt;&lt;TD&gt;TF&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;David&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Policies Sold: need distinct policy numbers&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Client Code&lt;/TD&gt;&lt;TD&gt;Policy Number&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Premium&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A123&lt;/TD&gt;&lt;TD&gt;11111&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 100.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B229&lt;/TD&gt;&lt;TD&gt;22222&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 300.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C234&lt;/TD&gt;&lt;TD&gt;33333&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;E762&lt;/TD&gt;&lt;TD&gt;44444&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 900.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A123&lt;/TD&gt;&lt;TD&gt;11111&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A123&lt;/TD&gt;&lt;TD&gt;55555&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 400.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to build a formula that shows a count of all policies sold only for those client codes where a TF activity was entered.&amp;nbsp; If more than one unique Policy Number exists on a client code I need to count each of these, but I would not want to count duplicates of the same policy number on the same client code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 17:04:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4157530#M165209</guid>
      <dc:creator>kfortenberry</dc:creator>
      <dc:date>2024-09-18T17:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: INTERSECT between 2 Tables with different Filter Values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4157565#M165210</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="705343" data-lia-user-login="kfortenberry" class="lia-mention lia-mention-user"&gt;kfortenberry&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can write a measure as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;measure count_policy := var tbl1= summarize( filter (activities, [activity type] = "TF") , activities [client code])&lt;/P&gt;&lt;P&gt;var tbl2 = summarize ( filter (policies sold , policies sold [client code] in tbl1) , policies sold [ client code] , policies sold [ policy number]&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;return countrows (tbl2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If this post helps, then I would appreciate a thumbs up&amp;nbsp;&amp;nbsp;and mark it as the solution&amp;nbsp;to help the other members find it more quickly.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Sep 2024 17:26:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4157565#M165210</guid>
      <dc:creator>Selva-Salimi</dc:creator>
      <dc:date>2024-09-18T17:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: INTERSECT between 2 Tables with different Filter Values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4158036#M165226</link>
      <description>&lt;P&gt;As there exist a many to many relationship across the two tables, create a calcuated column in the Policy table.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count Of Policies= COUNTX (
    SELECTCOLUMNS (
        FILTER ( RELATEDTABLE ( 'Activities' ), 'Activities'[Activity Type] = "TF" ),
        "Cnt", 'Policy'[Policy Number]
    ),
    'Policy'[Policy Number]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 23:32:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4158036#M165226</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-09-18T23:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: INTERSECT between 2 Tables with different Filter Values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4159934#M165290</link>
      <description>&lt;P&gt;Thank you for your assistance. I am receiving the following error when I try to implement this formula:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"A single value for column 'PolicyNumber' in table 'Policy' cannot be determined. Thias can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 13:54:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4159934#M165290</guid>
      <dc:creator>kfortenberry</dc:creator>
      <dc:date>2024-09-19T13:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: INTERSECT between 2 Tables with different Filter Values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4159941#M165292</link>
      <description>&lt;P&gt;You have to create a calculated column.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 13:56:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4159941#M165292</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-09-19T13:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: INTERSECT between 2 Tables with different Filter Values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4233290#M167430</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="705343" data-lia-user-login="kfortenberry" class="lia-mention lia-mention-user"&gt;kfortenberry&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have a good day.&amp;nbsp;Have you resolved the issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wearsky&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 09:09:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4233290#M167430</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-08T09:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: INTERSECT between 2 Tables with different Filter Values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4233426#M167432</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="705343" data-lia-user-login="kfortenberry" class="lia-mention lia-mention-user"&gt;kfortenberry&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding the many-to-many relationship, it appears that you need to create a separate dimension table for Client Code, and create a deta model like below, where many-to-one relatinoships are created for the two fact tables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Then, you can write a measure like below:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Activity TF =
CONCATENATEX (
    DISTINCT ( Activities[Activity Type] ),
    IF ( Activities[Activity Type] = "TF", Activities[Activity Type], BLANK () )
)
&lt;/LI-CODE&gt;
&lt;P&gt;Which is then brought to the Client Code dimension table,&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;This is brought through the normal relationship path to the other fact table, Policies Sold.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;You can then write a measure like the one below to identify the distinctcount of policy numbers where the client codes have an 'TF' activity type.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Policy Number distinctcount (TF) =
CALCULATE (
    DISTINCTCOUNT ( 'Policies Sold'[Policy Number] ),
    KEEPFILTERS ( 'Policies Sold'[TF] = "TF" )
)
&lt;/LI-CODE&gt;
&lt;P&gt;The resulting output is displayed below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Please let me know if the result is line with your expectations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached an example pbix file for your reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 10:57:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/INTERSECT-between-2-Tables-with-different-Filter-Values/m-p/4233426#M167432</guid>
      <dc:creator>DataNinja777</dc:creator>
      <dc:date>2024-10-08T10:57:28Z</dc:date>
    </item>
  </channel>
</rss>

