<?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 Count Distinct Text Column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Distinct-Text-Column/m-p/3786772#M147906</link>
    <description>&lt;P&gt;I am trying to use a card (z No of Roles) to count the distinct number of roles.&amp;nbsp; As you will see there is only one role - Project Delivery Manager (PDM).&amp;nbsp; I have used the following DAX for the card but they both return 2 instead of 1.&amp;nbsp; Any ideas:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;z_No of Roles = COUNTROWS(DISTINCT('Tasks Main'[Role]))&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;z_No of Roles =&lt;/SPAN&gt; &lt;SPAN&gt;DISTINCTCOUNT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Tasks Main'&lt;/SPAN&gt;&lt;SPAN&gt;[Role]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas why I am getting 2 instead of 1?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2024 17:22:03 GMT</pubDate>
    <dc:creator>spandy34</dc:creator>
    <dc:date>2024-03-22T17:22:03Z</dc:date>
    <item>
      <title>Count Distinct Text Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Distinct-Text-Column/m-p/3786772#M147906</link>
      <description>&lt;P&gt;I am trying to use a card (z No of Roles) to count the distinct number of roles.&amp;nbsp; As you will see there is only one role - Project Delivery Manager (PDM).&amp;nbsp; I have used the following DAX for the card but they both return 2 instead of 1.&amp;nbsp; Any ideas:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;z_No of Roles = COUNTROWS(DISTINCT('Tasks Main'[Role]))&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;z_No of Roles =&lt;/SPAN&gt; &lt;SPAN&gt;DISTINCTCOUNT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Tasks Main'&lt;/SPAN&gt;&lt;SPAN&gt;[Role]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas why I am getting 2 instead of 1?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 17:22:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Distinct-Text-Column/m-p/3786772#M147906</guid>
      <dc:creator>spandy34</dc:creator>
      <dc:date>2024-03-22T17:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct Text Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Distinct-Text-Column/m-p/3786827#M147908</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I think that DISTINCTCOUNT should do the work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Can you show your model and relationships ?&lt;BR /&gt;And can you verify that the value are truly equal ? (right click -&amp;gt; copy value). Check that there is no space behind the value for exemple&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 18:04:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Distinct-Text-Column/m-p/3786827#M147908</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-22T18:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct Text Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Distinct-Text-Column/m-p/3788466#M148022</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="333315" data-lia-user-login="spandy34" class="lia-mention lia-mention-user"&gt;spandy34&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp; said, sometimes text values that look the same can contain trailing spaces or invisible characters, causing them to be counted as different values.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Also, if you have a blank or null value in the "Role" column, that value will be counted as a non-duplicate, resulting in a count of 2. So, I created the following table with a space at the left and right ends of the second row of data, and a blank row in the fourth row.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At this point, use the expression&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;z_No of Roles = COUNTROWS(DISTINCT('Table'[role]))&lt;/LI-CODE&gt;
&lt;P&gt;The result of this calculation is 3.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;So you can use the TRIM function and exclude blank values to solve both problems.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;z_No of Roles2 =
COUNTROWS(
DISTINCT(
SELECTCOLUMNS(
FILTER('Table', 'Table'[role] &amp;lt;&amp;gt; BLANK()),
"TrimmedRole", TRIM('Table'[role])
)
)
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If your Current Period does not refer to this, please clarify in a follow-up reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Clara Gong&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 02:49:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Distinct-Text-Column/m-p/3788466#M148022</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-25T02:49:39Z</dc:date>
    </item>
  </channel>
</rss>

