<?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 Counting unique rows from a column after filtering another column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-unique-rows-from-a-column-after-filtering-another/m-p/1079961#M15212</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure that first filters out all rows from a date column that are older than a given date; and then, counts the rows in&amp;nbsp;the 'Document Key' column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Under1Year = COUNTX(FILTER('Inventory',[Content Current Date].[Date] &amp;gt;= CONVERT("03/01/2019",DATETIME)),'Inventory'[Document Key])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was working fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, there's an additional requirement to count only unique values from the column. I modified the formula as below but none of them worked.&lt;/P&gt;&lt;P&gt;This one gave the same result as the above original formula(which I know is incorrect as I manualy checked there &lt;U&gt;are&lt;/U&gt; duplicate values present in the 'Document Key' column after the date filter is applied)&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;Under1Year = COUNTX(FILTER('Inventory',[Content Current Date].[Date] &amp;gt;= CONVERT("03/01/2019",DATETIME)),DISTINCTCOUNT('Inventory'[Document Key]))&lt;/LI-CODE&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;Then I tried this one and, as expected, it threw a runtime error as DISTINCTCOUNT only accepts a column as an argument.&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;Under1Year = DISTINCTCOUNT(COUNTX(FILTER('Inventory',[Content Current Date].[Date] &amp;gt;= CONVERT("03/01/2019",DATETIME)),'Inventory'[Document Key]))&lt;/LI-CODE&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;Any ideas how to modify the formula so it only counts unique rows in the 'Document Key' column?&lt;BR /&gt;&lt;BR /&gt;- Regards.&lt;/P&gt;</description>
    <pubDate>Thu, 07 May 2020 18:58:40 GMT</pubDate>
    <dc:creator>Enigma</dc:creator>
    <dc:date>2020-05-07T18:58:40Z</dc:date>
    <item>
      <title>Counting unique rows from a column after filtering another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-unique-rows-from-a-column-after-filtering-another/m-p/1079961#M15212</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure that first filters out all rows from a date column that are older than a given date; and then, counts the rows in&amp;nbsp;the 'Document Key' column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Under1Year = COUNTX(FILTER('Inventory',[Content Current Date].[Date] &amp;gt;= CONVERT("03/01/2019",DATETIME)),'Inventory'[Document Key])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was working fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, there's an additional requirement to count only unique values from the column. I modified the formula as below but none of them worked.&lt;/P&gt;&lt;P&gt;This one gave the same result as the above original formula(which I know is incorrect as I manualy checked there &lt;U&gt;are&lt;/U&gt; duplicate values present in the 'Document Key' column after the date filter is applied)&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;Under1Year = COUNTX(FILTER('Inventory',[Content Current Date].[Date] &amp;gt;= CONVERT("03/01/2019",DATETIME)),DISTINCTCOUNT('Inventory'[Document Key]))&lt;/LI-CODE&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;Then I tried this one and, as expected, it threw a runtime error as DISTINCTCOUNT only accepts a column as an argument.&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;Under1Year = DISTINCTCOUNT(COUNTX(FILTER('Inventory',[Content Current Date].[Date] &amp;gt;= CONVERT("03/01/2019",DATETIME)),'Inventory'[Document Key]))&lt;/LI-CODE&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;Any ideas how to modify the formula so it only counts unique rows in the 'Document Key' column?&lt;BR /&gt;&lt;BR /&gt;- Regards.&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 18:58:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-unique-rows-from-a-column-after-filtering-another/m-p/1079961#M15212</guid>
      <dc:creator>Enigma</dc:creator>
      <dc:date>2020-05-07T18:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Counting unique rows from a column after filtering another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-unique-rows-from-a-column-after-filtering-another/m-p/1080353#M15232</link>
      <description>&lt;P&gt;How about this measure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NewMeasure = calculate(distinctcount(Inventory[Customer Key]), [Content Current Date].[Date] &amp;gt;= CONVERT("03/01/2019", DATETIME))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A couple questions though.&amp;nbsp; Why are you converting to DateTime?&amp;nbsp; Is your Date column in that format?&amp;nbsp; Would &amp;gt;= Date(2019,3,1) work in its place?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I would also suggest having a separate Date table and turn off the Auto date hierarchies (.[Date]).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this works for you, please mark it as the solution.&amp;nbsp; Kudos are appreciated too.&amp;nbsp; Please let me know if not.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 01:32:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-unique-rows-from-a-column-after-filtering-another/m-p/1080353#M15232</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-05-08T01:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Counting unique rows from a column after filtering another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-unique-rows-from-a-column-after-filtering-another/m-p/1081252#M15253</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226208" data-lia-user-login="mahoneypat" class="lia-mention lia-mention-user"&gt;mahoneypat&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked perfectly!&lt;/P&gt;&lt;P&gt;And to answer your questions, I was converting the date as I was not aware how to use the DATE function. Now that I do, I am using that and not converting.&lt;/P&gt;&lt;P&gt;About a separate Date table - well, again, I don't have much idea about. Will do a bit of research. Any resources you can suggest that explains the pros and cons versus using date hierarchies?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 11:18:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-unique-rows-from-a-column-after-filtering-another/m-p/1081252#M15253</guid>
      <dc:creator>Enigma</dc:creator>
      <dc:date>2020-05-08T11:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Counting unique rows from a column after filtering another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-unique-rows-from-a-column-after-filtering-another/m-p/1081333#M15262</link>
      <description>&lt;P&gt;Glad it worked for you.&amp;nbsp; Here are some useful links with more info.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=d4yAzhIQqNk" target="_blank" rel="noopener"&gt;https://www.youtube.com/watch?v=d4yAzhIQqNk&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/" target="_blank" rel="noopener"&gt;https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 12:25:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-unique-rows-from-a-column-after-filtering-another/m-p/1081333#M15262</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-05-08T12:25:57Z</dc:date>
    </item>
  </channel>
</rss>

