<?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: Multi level distinct counting in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multi-level-distinct-counting/m-p/4062512#M161267</link>
    <description>&lt;P&gt;&lt;FONT&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="758931" data-lia-user-login="maashi" class="lia-mention lia-mention-user"&gt;maashi&lt;/a&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, you need to create a measure to calculate how many reasons one "sales no" has:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Reason count = 
VAR _no = SELECTEDVALUE(fact_NCP_Reporting[Sales Order No])

RETURN
CALCULATE(DISTINCTCOUNT(fact_NCP_Reporting[NCP Reason Categories.Reason Category]),FILTER(ALL(fact_NCP_Reporting),'fact_NCP_Reporting'[Sales Order No] = _no))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then modify your original measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Freight Count = 
CALCULATE(
            DISTINCTCOUNT(
                fact_NCP_Reporting[Sales Order No]),
                FILTER(ALL('fact_NCP_Reporting'),
                'fact_NCP_Reporting'[NCP Reason Categories.Reason Category]="Freight"&amp;amp;&amp;amp;[Reason count]=1)
                )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jayleny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jul 2024 02:13:43 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-07-26T02:13:43Z</dc:date>
    <item>
      <title>Multi level distinct counting</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multi-level-distinct-counting/m-p/4062299#M161256</link>
      <description>&lt;P&gt;I'm trying to count some customer complaints with multiple filters, and am a bit stumped on how to write this measure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Link to sample data:&lt;/P&gt;&lt;P&gt;&lt;A href="https://altusnzltd-my.sharepoint.com/:x:/g/personal/marcy_henderson_altus_co_nz/Eeah0L-uBNVOrgb7KTfrvokBhgrf0JKY-PtZauz6rsJs9w?e=xkoU4S" target="_blank" rel="noopener"&gt;Freight snapshot.xlsx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to count some freight complaints that only have freight related reasons and nothing else.&lt;/P&gt;&lt;P&gt;A unique Sales Order Number can have several lines, and not every line has to have the same Material Return Reason. I want a&amp;nbsp;&lt;U&gt;distinct&lt;/U&gt; count of sales orders that contain line(s) of freight, nothing else.&amp;nbsp; So in the sample data I do not want to count Sales Orders 2017867 or 2009388 because it contains freight and other defect reasons. But I want to count 2016014, 2011927, 2013299, 2009417, 2010615. If there are multiple lines in the same sales order, as long as all the lines are freight, I will count it. (2010615 is a good example of this)&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, if I count the data set, I want the answer to be 5.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Counting all freight lines is easy with a distinct count and a freight filter :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Freight Count =&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;DISTINCTCOUNT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;fact_NCP_Reporting&lt;/SPAN&gt;&lt;SPAN&gt;[Sales Order No]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'fact_NCP_Reporting'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'fact_NCP_Reporting'&lt;/SPAN&gt;&lt;SPAN&gt;[NCP Reason Categories.Reason Category]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"Freight"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But how do I add a second filter in to look at any other lines the same sales order contains and see if it contains any other return reasons besides freight?&lt;BR /&gt;&lt;BR /&gt;Thanks for your help&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 25 Jul 2024 22:50:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multi-level-distinct-counting/m-p/4062299#M161256</guid>
      <dc:creator>maashi</dc:creator>
      <dc:date>2024-07-25T22:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Multi level distinct counting</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multi-level-distinct-counting/m-p/4062512#M161267</link>
      <description>&lt;P&gt;&lt;FONT&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="758931" data-lia-user-login="maashi" class="lia-mention lia-mention-user"&gt;maashi&lt;/a&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, you need to create a measure to calculate how many reasons one "sales no" has:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Reason count = 
VAR _no = SELECTEDVALUE(fact_NCP_Reporting[Sales Order No])

RETURN
CALCULATE(DISTINCTCOUNT(fact_NCP_Reporting[NCP Reason Categories.Reason Category]),FILTER(ALL(fact_NCP_Reporting),'fact_NCP_Reporting'[Sales Order No] = _no))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then modify your original measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Freight Count = 
CALCULATE(
            DISTINCTCOUNT(
                fact_NCP_Reporting[Sales Order No]),
                FILTER(ALL('fact_NCP_Reporting'),
                'fact_NCP_Reporting'[NCP Reason Categories.Reason Category]="Freight"&amp;amp;&amp;amp;[Reason count]=1)
                )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jayleny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 02:13:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multi-level-distinct-counting/m-p/4062512#M161267</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-26T02:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Multi level distinct counting</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multi-level-distinct-counting/m-p/4065609#M161400</link>
      <description>&lt;P&gt;1st created the sales order repeatation count&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Freight count with respect to sales order no is calculated&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Freight count and sales order repeatation number is compared&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Net sales order number is calculated&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;If this solves your problem then accept the same as your solution&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2024 15:53:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multi-level-distinct-counting/m-p/4065609#M161400</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-28T15:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multi level distinct counting</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multi-level-distinct-counting/m-p/4065715#M161407</link>
      <description>&lt;P&gt;This worked perfectly. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2024 22:10:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Multi-level-distinct-counting/m-p/4065715#M161407</guid>
      <dc:creator>maashi</dc:creator>
      <dc:date>2024-07-28T22:10:31Z</dc:date>
    </item>
  </channel>
</rss>

