<?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: Count if both products is bought in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029751#M45488</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;I wrote something similar to this&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Together/td-p/2002588" target="_blank" rel="noopener"&gt;Better Together - Microsoft Power BI Community&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, I think in your case:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure Count = 
  VAR __Values = DISTINCT('Slicer'[Product])
  VAR __Table = 
    DISTINCT(
      FILTER(
        SELECTCOLUMNS('Datatable',"__Customer",[Customer],"__Product",[Product]),
        [__Product] IN __Values
      )
    )
  VAR __Table1 = GROUPBY(__Table,[__Customer],"__Count",COUNTX(CURRENTGROUP(),[__Product]))
RETURN
  COUNTROWS(FILTER(__Table1,[__Count] = COUNTROWS(__Values))) * COUNTROWS(__Values)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 21 Aug 2021 14:06:35 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2021-08-21T14:06:35Z</dc:date>
    <item>
      <title>Count if both products is bought</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029638#M45483</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need some Dax help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trying to calculate how many products is bought of all customers only&amp;nbsp;&lt;U&gt;if they have bought all chosen&lt;/U&gt; products.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I filter in a slicer on Product "XX" AND "YY" a simple count measure would give me the result "6"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But as said I only want it to count the products if the same customer bought both products chosen in the slicer. So the result should be "4", As only customer A and B bought both products.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Real data is larger with more products and customers and the amount of products chosen can be more than two.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Datatable simplyfied:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Customer&lt;/TD&gt;&lt;TD&gt;Product&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;XX&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;YY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;XX&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;YY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;XX&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;C&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;ZZ&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;TD&gt;YY&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Sat, 21 Aug 2021 11:11:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029638#M45483</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-21T11:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Count if both products is bought</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029751#M45488</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;I wrote something similar to this&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Together/td-p/2002588" target="_blank" rel="noopener"&gt;Better Together - Microsoft Power BI Community&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, I think in your case:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure Count = 
  VAR __Values = DISTINCT('Slicer'[Product])
  VAR __Table = 
    DISTINCT(
      FILTER(
        SELECTCOLUMNS('Datatable',"__Customer",[Customer],"__Product",[Product]),
        [__Product] IN __Values
      )
    )
  VAR __Table1 = GROUPBY(__Table,[__Customer],"__Count",COUNTX(CURRENTGROUP(),[__Product]))
RETURN
  COUNTROWS(FILTER(__Table1,[__Count] = COUNTROWS(__Values))) * COUNTROWS(__Values)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 14:06:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029751#M45488</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-21T14:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Count if both products is bought</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029919#M45494</link>
      <description>&lt;P&gt;Correct modeling results in simple solution,&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 18:29:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029919#M45494</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2021-08-21T18:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Count if both products is bought</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029935#M45497</link>
      <description>&lt;P&gt;Hi Again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your quick help - really appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I think you are almost there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only thing is that it shouldn't be a distinct count.&amp;nbsp;&lt;/P&gt;&lt;P&gt;From your shown dataset the answer should "4", as customer C&amp;amp;D (who bought both products) in total bought 4 products.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to change?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 19:01:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029935#M45497</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-21T19:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Count if both products is bought</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029941#M45498</link>
      <description>&lt;P&gt;Hi Greg,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help - really great..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe you are not far away from the result i'm searching for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only thing is that your measure dosen't seem to count more of the same products per Customer.&lt;/P&gt;&lt;P&gt;If the same customer bought more than one of the same product it needs to be counting all of them and not only once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does it makes sence? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 19:08:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029941#M45498</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-21T19:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Count if both products is bought</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029946#M45499</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;Maybe. Try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure Count = 
  VAR __Values = DISTINCT('Slicer'[Product])
  VAR __Table = 
    DISTINCT(
      FILTER(
        SELECTCOLUMNS('Datatable',"__Customer",[Customer],"__Product",[Product]),
        [__Product] IN __Values
      )
    )
  VAR __Table1 = GROUPBY(__Table,[__Customer],"__Count",COUNTX(CURRENTGROUP(),[__Product]))
  VAR __Table2 = SELECTCOLUMNS(FILTER(__Table1,[__Count] = COUNTROWS(__Values)),"__Customer",[__Customer])
RETURN
  COUNTROWS(FILTER(Datatable,[Customer] IN __Table2 &amp;amp;&amp;amp; [Product] IN __Values))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 19:19:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2029946#M45499</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-21T19:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count if both products is bought</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2030183#M45515</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp; - You are the man and came first to the finish line.&lt;/P&gt;&lt;P&gt;Thanks for your help - much appreciated&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I'll take time to read your Better Together Topic &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Aug 2021 08:11:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-if-both-products-is-bought/m-p/2030183#M45515</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-22T08:11:27Z</dc:date>
    </item>
  </channel>
</rss>

