<?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: Calculate Distinct values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Distinct-values/m-p/2380228#M61476</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="268265" data-lia-user-login="chavanr" class="lia-mention lia-mention-user"&gt;chavanr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please consider sharing more details about it&amp;nbsp;and posting expected result so it is clear on what needs to be implemented?&amp;nbsp; And It would be great if there is a sample file without any sesentive information here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It makes it easier to give you a solution.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Sample (dummy dataset) data as text, use the table tool in the editing bar&lt;/LI&gt;
&lt;LI&gt;Expected output from sample data&lt;/LI&gt;
&lt;LI&gt;Explanation in words of how to get from 1. to 2.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Zeon Zheng&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&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>Tue, 08 Mar 2022 05:05:36 GMT</pubDate>
    <dc:creator>v-angzheng-msft</dc:creator>
    <dc:date>2022-03-08T05:05:36Z</dc:date>
    <item>
      <title>Calculate Distinct values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Distinct-values/m-p/2373852#M61040</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just wondering if someone can help with the below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate distinct value for my measure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Serious Incident Total = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&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;[Total Incidents]&lt;/SPAN&gt;&lt;SPAN&gt; - &lt;/SPAN&gt;&lt;SPAN&gt;[Total Not Serious Incidents]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Forms&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;NOT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Forms[Category]&lt;/SPAN&gt;&lt;SPAN&gt;)))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Total Not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t;,&lt;/SPAN&gt;&lt;SPAN&gt;Forms[Form Type]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"Incident &amp;amp; Investigation"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 04 Mar 2022 01:42:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Distinct-values/m-p/2373852#M61040</guid>
      <dc:creator>chavanr</dc:creator>
      <dc:date>2022-03-04T01:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distinct values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Distinct-values/m-p/2373997#M61046</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="268265" data-lia-user-login="chavanr" class="lia-mention lia-mention-user"&gt;chavanr&lt;/a&gt; , if want distinct values a measure first you need to get a grouping for that &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;measure =&lt;/P&gt;
&lt;P&gt;var _tab = summarize(Forms,Forms[Column], "_1",[Total Incidents ])&lt;/P&gt;
&lt;P&gt;return&lt;/P&gt;
&lt;P&gt;countx(values(_tab[_1],[_1])&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;measure =&lt;/P&gt;
&lt;P&gt;var _tab = summarize(Forms,Forms[Column], "_1",[Total Incidents ])&lt;/P&gt;
&lt;P&gt;return&lt;/P&gt;
&lt;P&gt;countx(summarize(_tab, _tab[_1],[_1])&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2022 03:16:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Distinct-values/m-p/2373997#M61046</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-03-04T03:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distinct values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Distinct-values/m-p/2380228#M61476</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="268265" data-lia-user-login="chavanr" class="lia-mention lia-mention-user"&gt;chavanr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please consider sharing more details about it&amp;nbsp;and posting expected result so it is clear on what needs to be implemented?&amp;nbsp; And It would be great if there is a sample file without any sesentive information here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It makes it easier to give you a solution.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Sample (dummy dataset) data as text, use the table tool in the editing bar&lt;/LI&gt;
&lt;LI&gt;Expected output from sample data&lt;/LI&gt;
&lt;LI&gt;Explanation in words of how to get from 1. to 2.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Zeon Zheng&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&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>Tue, 08 Mar 2022 05:05:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Distinct-values/m-p/2380228#M61476</guid>
      <dc:creator>v-angzheng-msft</dc:creator>
      <dc:date>2022-03-08T05:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Distinct values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Distinct-values/m-p/2380459#M61481</link>
      <description>&lt;P&gt;This should get you the result you wanted- worked for my test:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Serious Incident Total =
VAR _Incidents = CALCULATETABLE(
    DISTINCT( Forms[itrak_formid] ),
    Forms[Form Type] = "Incident &amp;amp; Investigation"
) 
VAR _NotSerious = CALCULATETABLE(
    DISTINCT( Forms[itrak_formid] ),
    Forms[Category] = "Not Serious"
) 

RETURN
COUNTROWS(
    EXCEPT( _Incidents, _NotSerious )
)&lt;/LI-CODE&gt;
&lt;P&gt;We create a table of distinct incidents (_Incidents), a table of distinct not serious forms (_NotSerious),&lt;/P&gt;
&lt;P&gt;Remove IDs that appear in&amp;nbsp;_NotSerious from _Incidents,&lt;/P&gt;
&lt;P&gt;And count the rows on the resulting table.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 06:59:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Distinct-values/m-p/2380459#M61481</guid>
      <dc:creator>rbriga</dc:creator>
      <dc:date>2022-03-08T06:59:57Z</dc:date>
    </item>
  </channel>
</rss>

