<?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: DistinctCount OF Ranks in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321393#M124316</link>
    <description>&lt;P&gt;Hello sir,&lt;/P&gt;&lt;P&gt;thank you so much to reply me, but what i want to achieve is not that, it's actually so simple&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it's so easy to achieve with the calculated column, but i want it to be inside the measure, to follow other filtrations that may occur, is it possible??!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;why i can't use this variable column i did just as i did it up there this is sooo frustrating!!!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 08 Jul 2023 13:31:25 GMT</pubDate>
    <dc:creator>Amrselim1989</dc:creator>
    <dc:date>2023-07-08T13:31:25Z</dc:date>
    <item>
      <title>DistinctCount OF Ranks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321214#M124305</link>
      <description>&lt;P&gt;Hello Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;kindly note i have the below code which is working fine and gives me the rank i want..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT&gt;&lt;FONT&gt;Rank&lt;/FONT&gt;&lt;FONT&gt; = &lt;/FONT&gt;&lt;FONT&gt;VAR&lt;/FONT&gt;&lt;FONT&gt; SourceTable = &lt;/FONT&gt;&lt;FONT&gt;ADDCOLUMNS&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt; &lt;FONT&gt;ALL&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt;&lt;FONT&gt; Sales[ItemCode] &lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt;, &lt;/FONT&gt;&lt;FONT&gt;"@Amt"&lt;/FONT&gt;&lt;FONT&gt;, [Sum of Net Sales Value] &lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt; &lt;BR /&gt;VAR&lt;/FONT&gt;&lt;FONT&gt; Result = &lt;/FONT&gt;&lt;FONT&gt;RANK&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt; &lt;FONT&gt;DENSE&lt;/FONT&gt;&lt;FONT&gt;, SourceTable, &lt;/FONT&gt;&lt;FONT&gt;ORDERBY&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt;&lt;FONT&gt; [@Amt], &lt;/FONT&gt;&lt;FONT&gt;DESC&lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt; &lt;FONT&gt;)&lt;/FONT&gt; &lt;FONT&gt; &lt;BR /&gt;RETURN&lt;/FONT&gt;&lt;FONT&gt; Result&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;but what i want to achieve is to distinct_count of the ranks itself, so i was thinking to create a variable table inside the measure, and then use distinct count to count the ranks something like this,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT&gt;&lt;FONT&gt; Rank&lt;/FONT&gt;&lt;FONT&gt; = &lt;/FONT&gt;&lt;FONT&gt;ADDCOLUMNS&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt; &lt;FONT&gt;ALL&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt;&lt;FONT&gt; Sales[ItemCode] &lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt;, &lt;/FONT&gt;&lt;FONT&gt;"@Amt"&lt;/FONT&gt;&lt;FONT&gt;, [Sum of Net Sales Value] &lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt; &lt;FONT&gt; &lt;BR /&gt;VAR&lt;/FONT&gt;&lt;FONT&gt; Result = &lt;/FONT&gt;&lt;FONT&gt;RANK&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt; &lt;FONT&gt;DENSE&lt;/FONT&gt;&lt;FONT&gt;, SourceTable, &lt;/FONT&gt;&lt;FONT&gt;ORDERBY&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt;&lt;FONT&gt; [@Amt], &lt;/FONT&gt;&lt;FONT&gt;DESC&lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt; &lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt; &lt;BR /&gt;VAR&lt;/FONT&gt;&lt;FONT&gt; _DisCount = &lt;/FONT&gt;&lt;FONT&gt;ADDCOLUMNS&lt;/FONT&gt;&lt;FONT&gt;(&lt;/FONT&gt;&lt;FONT&gt;ALL&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt;&lt;FONT&gt; Sales[ItemCode] &lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt;,&lt;/FONT&gt;&lt;FONT&gt;"@Rank"&lt;/FONT&gt;&lt;FONT&gt;,Result&lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt; &lt;BR /&gt;VAR&lt;/FONT&gt;&lt;FONT&gt; _Dis_Count = &lt;/FONT&gt;&lt;FONT&gt;distinctcount&lt;/FONT&gt;&lt;FONT&gt;(&lt;/FONT&gt;&lt;FONT&gt;_DisCount,[@Rank]&lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt; &lt;BR /&gt;RETURN&lt;/FONT&gt;&lt;FONT&gt; Result &amp;amp; &lt;/FONT&gt;&lt;FONT&gt;"of"&lt;/FONT&gt;&lt;FONT&gt; _Dis_Count&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;so i can say that product is rank 2 of 25 total ranks,&lt;/P&gt;&lt;P&gt;i want it in the same measure not with a separated table outside, is it possible, i don't know why i can't use this variable column [Rank] like this ??!!!!&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jul 2023 06:10:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321214#M124305</guid>
      <dc:creator>Amrselim1989</dc:creator>
      <dc:date>2023-07-08T06:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: DistinctCount OF Ranks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321255#M124309</link>
      <description>&lt;P&gt;Hi, I am not sure what is the expected result, but I tried to create a sample pbix file like below.&lt;BR /&gt;Please check the below picture and the attached pbix file.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Distinct count of rank = 
VAR _SourceTable =
    ADDCOLUMNS ( ALL ( Sales[ItemCode] ), "@Amt", [Sum of Net Sales Value] )
VAR _currentrowrank =
    RANK ( DENSE, _SourceTable, ORDERBY ( [@Amt], DESC ) )
VAR _DisCount =
    FILTER (
        ADDCOLUMNS (
            ALL ( Sales[ItemCode] ),
            "@Rank", RANK ( DENSE, _SourceTable, ORDERBY ( [@Amt], DESC ) )
        ),
        [@Rank] = _currentrowrank
    )
VAR _Dis_Count =
    COUNTROWS ( _DisCount )
RETURN
    _Dis_Count&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 08 Jul 2023 07:44:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321255#M124309</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2023-07-08T07:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: DistinctCount OF Ranks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321393#M124316</link>
      <description>&lt;P&gt;Hello sir,&lt;/P&gt;&lt;P&gt;thank you so much to reply me, but what i want to achieve is not that, it's actually so simple&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it's so easy to achieve with the calculated column, but i want it to be inside the measure, to follow other filtrations that may occur, is it possible??!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;why i can't use this variable column i did just as i did it up there this is sooo frustrating!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jul 2023 13:31:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321393#M124316</guid>
      <dc:creator>Amrselim1989</dc:creator>
      <dc:date>2023-07-08T13:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: DistinctCount OF Ranks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321556#M124327</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Distinct count of rank V2 =
VAR _SourceTable =
    ADDCOLUMNS ( ALL ( Sales[ItemCode] ), "@Amt", [Sum of Net Sales Value] )
VAR _currentrowrank =
    RANK ( DENSE, _SourceTable, ORDERBY ( [@Amt], DESC ) )
VAR _t =
    SUMMARIZE (
        ADDCOLUMNS (
            ALL ( Sales[ItemCode] ),
            "@Rank", RANK ( DENSE, _SourceTable, ORDERBY ( [@Amt], DESC ) )
        ),
        [@Rank]
    )
VAR _Dis_Count =
    COUNTROWS ( _t )
RETURN
    _Dis_Count
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another way to achieve this is, I think, try to get the last rank number in the rank result.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jul 2023 19:09:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321556#M124327</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2023-07-08T19:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: DistinctCount OF Ranks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321644#M124337</link>
      <description>&lt;P&gt;Yes, Thank you so much, i just knew that i have to use the X aggregation function inside the variable tables to be able to use their column like MAXX instead of the distinct count...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2023 00:37:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DistinctCount-OF-Ranks/m-p/3321644#M124337</guid>
      <dc:creator>Amrselim1989</dc:creator>
      <dc:date>2023-07-09T00:37:35Z</dc:date>
    </item>
  </channel>
</rss>

