<?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: Distinct count by max date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4008092#M157190</link>
    <description>&lt;P&gt;Hi,&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="764863" data-lia-user-login="lnik" class="lia-mention lia-mention-user"&gt;lnik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am glad to help you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, you want to distinct count by max date?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I understand you correctly, then you can refer to my solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You can start by creating a new table.&amp;nbsp;&lt;/LI&gt;
&lt;/OL&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;LI-CODE lang="markup"&gt;Table 2 = 
VAR _distinct =
    SUMMARIZE (
        'Table',
        'Table'[Item],
        'Table'[Customer],
        'Table'[Date Visit],
        "MaxDate",
            CALCULATE (
                MAX ( 'Table'[Date Visit] ),
                FILTER ( ALL ( 'Table' ), 'Table'[Item] = EARLIER ( 'Table'[Item] ) )
            )
    )
RETURN
    FILTER (
        _distinct,
        IF ( 'Table'[Item] = 3, BLANK (), 'Table'[Date Visit] = [MaxDate] )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL start="2"&gt;
&lt;LI&gt;Create a Measure for calculating the number of rows corresponding to each Item, and you'll end up with the result you want.&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DistinctCount = 
VAR _currentItem =
    MAX ( 'Table 2'[Item] )
RETURN
    COUNTROWS ( FILTER ( ALL ( 'Table 2'[Item] ), 'Table 2'[Item] = _currentItem ) )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.&lt;BR /&gt;Best Regards,&lt;BR /&gt;Fen Ling,&lt;BR /&gt;If this post &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jun 2024 03:03:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-06-25T03:03:38Z</dc:date>
    <item>
      <title>Distinct count by max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4006586#M156842</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I am trying to calculate &lt;SPAN&gt;distinct values based on max date column.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;But with measure&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DistinctCount =&lt;/SPAN&gt; &lt;SPAN&gt;calculate&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DISTINCTCOUNT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Table1&lt;/SPAN&gt;&lt;SPAN&gt;[Item]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;Table1&lt;/SPAN&gt;&lt;SPAN&gt;[Date Visit]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Table1&lt;/SPAN&gt;&lt;SPAN&gt;[Date Visit]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;it count also Item 3&amp;nbsp;although he is not with max date.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 24 Jun 2024 09:10:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4006586#M156842</guid>
      <dc:creator>lnik</dc:creator>
      <dc:date>2024-06-24T09:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count by max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4006699#M156849</link>
      <description>&lt;P&gt;Hello friend,&amp;nbsp;&lt;BR /&gt;I have tried the same formula you mentioned...its working....sharing the snaps&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Please let me know the problem you are facing.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 10:09:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4006699#M156849</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-24T10:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count by max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4007112#M156899</link>
      <description>&lt;P&gt;I want to use ut in matrix visualisation but there it shows 1 against item 3 and I expect it to be empty&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, 24 Jun 2024 14:11:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4007112#M156899</guid>
      <dc:creator>lnik</dc:creator>
      <dc:date>2024-06-24T14:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count by max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4008092#M157190</link>
      <description>&lt;P&gt;Hi,&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="764863" data-lia-user-login="lnik" class="lia-mention lia-mention-user"&gt;lnik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am glad to help you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, you want to distinct count by max date?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I understand you correctly, then you can refer to my solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You can start by creating a new table.&amp;nbsp;&lt;/LI&gt;
&lt;/OL&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;LI-CODE lang="markup"&gt;Table 2 = 
VAR _distinct =
    SUMMARIZE (
        'Table',
        'Table'[Item],
        'Table'[Customer],
        'Table'[Date Visit],
        "MaxDate",
            CALCULATE (
                MAX ( 'Table'[Date Visit] ),
                FILTER ( ALL ( 'Table' ), 'Table'[Item] = EARLIER ( 'Table'[Item] ) )
            )
    )
RETURN
    FILTER (
        _distinct,
        IF ( 'Table'[Item] = 3, BLANK (), 'Table'[Date Visit] = [MaxDate] )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL start="2"&gt;
&lt;LI&gt;Create a Measure for calculating the number of rows corresponding to each Item, and you'll end up with the result you want.&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DistinctCount = 
VAR _currentItem =
    MAX ( 'Table 2'[Item] )
RETURN
    COUNTROWS ( FILTER ( ALL ( 'Table 2'[Item] ), 'Table 2'[Item] = _currentItem ) )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.&lt;BR /&gt;Best Regards,&lt;BR /&gt;Fen Ling,&lt;BR /&gt;If this post &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 03:03:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4008092#M157190</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-25T03:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count by max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4010494#M157812</link>
      <description>&lt;P&gt;Thank you, works perfectly!&lt;/P&gt;&lt;P&gt;One more question.&lt;/P&gt;&lt;P&gt;Is it possible if i add slicer for year and month, when selecting a specific month it dynamically to calculate distinct count for the items based on the maximum date for that month?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 06:21:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-count-by-max-date/m-p/4010494#M157812</guid>
      <dc:creator>lnik</dc:creator>
      <dc:date>2024-06-26T06:21:16Z</dc:date>
    </item>
  </channel>
</rss>

