<?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: Aggregating conditional distinct counts in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3148771#M112739</link>
    <description>&lt;P&gt;Thanks for the reply. It hasn't quite worked for my scenario (I've edited the OP to reflect desried output)... but I'm now trying to use countx() and values() to see if I can modify my measures to suit.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Mar 2023 03:43:27 GMT</pubDate>
    <dc:creator>ScottKC</dc:creator>
    <dc:date>2023-03-23T03:43:27Z</dc:date>
    <item>
      <title>Aggregating conditional distinct counts</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3148565#M112725</link>
      <description>&lt;P&gt;hi all&lt;/P&gt;&lt;P&gt;How could I achieve the following in a measure? An aggregate count of distinct Customers who had sales in all Channels (A,B,C)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;CustomerName&lt;/TD&gt;&lt;TD&gt;Channel&lt;/TD&gt;&lt;TD&gt;SaleAmount&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;22/01/2023&lt;/TD&gt;&lt;TD&gt;Lisa&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;$2.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;22/02/2023&lt;/TD&gt;&lt;TD&gt;Lisa&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;$20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t;Maggie&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;$17.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;22/03/2023&lt;/TD&gt;&lt;TD&gt;Maggie&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;$17.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Quite simple to get the distinct count of customers = 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can also get the distinct count of customers for each Channel:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;A = 2 customers (Lisa and Maggie)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;B = 3 customers (Lisa, Bart and Maggie)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;C = 4 customers (Lisa, Homer, Bart and Maggie)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But am struggle to the distinct count of customers who have a record in each channel = 2 (Lisa and Maggie)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;The desired output would look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CustomerName&lt;/TD&gt;&lt;TD&gt;Channel A flag&lt;/TD&gt;&lt;TD&gt;Channel B flag&lt;/TD&gt;&lt;TD&gt;Channel C flag&lt;/TD&gt;&lt;TD&gt;All Channels flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Lisa&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bart&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Maggie&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Homer&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;TOTALS&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 03:26:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3148565#M112725</guid>
      <dc:creator>ScottKC</dc:creator>
      <dc:date>2023-03-23T03:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating conditional distinct counts</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3148602#M112729</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="447795" data-lia-user-login="ScottKC" class="lia-mention lia-mention-user"&gt;ScottKC&lt;/a&gt; , Try measures like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;M1 = countrows(Values(Table[CustomerName]))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;M2 = countx(Values([Channel]), if([M1] &amp;gt;=2, [Channel], blank()))&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 01:52:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3148602#M112729</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2023-03-23T01:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating conditional distinct counts</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3148771#M112739</link>
      <description>&lt;P&gt;Thanks for the reply. It hasn't quite worked for my scenario (I've edited the OP to reflect desried output)... but I'm now trying to use countx() and values() to see if I can modify my measures to suit.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 03:43:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3148771#M112739</guid>
      <dc:creator>ScottKC</dc:creator>
      <dc:date>2023-03-23T03:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating conditional distinct counts</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3154822#M113126</link>
      <description>&lt;P&gt;I think logic like the following should work&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;All Channels Count = 
// get the list of customers and count the distinct channels for each customer
var CustChannels =  summarize('Table', 'Table'[CustomerName], "ChannelCount", DISTINCTCOUNT( 'Table'[Channel]))
// get the total distinc channels regardless of the filter context
var distinctChannels =COUNTROWS(DISTINCT(ALL('Table'[Channel])))
// count the customers where the number of channels is the same as to the total distinct channels
return countrows(Filter(CustChannels, [ChannelCount] = distinctChannels))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is giving me the output on the last column&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 00:18:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3154822#M113126</guid>
      <dc:creator>d_gosbell</dc:creator>
      <dc:date>2023-03-27T00:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating conditional distinct counts</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3248545#M119785</link>
      <description>&lt;P&gt;I have a similar challenge:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trying to count unique names (same people repeatedly occur in table rows) in a table based on some other column's categorical status:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Homer&lt;/P&gt;&lt;P&gt;Marge&lt;/P&gt;&lt;P&gt;Maggie&lt;/P&gt;&lt;P&gt;Bart&lt;BR /&gt;Maggie&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maggie&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;They all have a categorical status of "Red, Blue, or Green"&amp;nbsp; and I wanted to count each employee only once, that hs "red" status.&amp;nbsp; &amp;nbsp; &amp;nbsp; Can't seem to find the DAX expression for this, or steps to create columns or measures to do this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 20:53:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregating-conditional-distinct-counts/m-p/3248545#M119785</guid>
      <dc:creator>ninjaryder1st</dc:creator>
      <dc:date>2023-05-22T20:53:28Z</dc:date>
    </item>
  </channel>
</rss>

