<?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 RANKX - Unable to RANK Rows For Each Category in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3362442#M126427</link>
    <description>&lt;P&gt;Hello Community -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Frustrated with myself that I can't figure this out.&lt;/P&gt;&lt;P&gt;I've read about 10-15 related pages on forums, SQLBI etc., but still failing.&lt;/P&gt;&lt;P&gt;Seems like this should be incredibly easy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All I want to do is rank the rows for each City within a table visual based on Data[Unique ID].&lt;/P&gt;&lt;P&gt;NOTES:&lt;/P&gt;&lt;P&gt;- There can be no ties.&lt;/P&gt;&lt;P&gt;- Dummy data set is shown below.&lt;/P&gt;&lt;P&gt;- Since there is no unique column to break ties, I created the calculated column "Unique ID".&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;Desired outcome is a table visual that shows the following Excel mock-up data:&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;Regards,&lt;/P&gt;&lt;P&gt;Nathan&lt;/P&gt;</description>
    <pubDate>Wed, 02 Aug 2023 20:44:41 GMT</pubDate>
    <dc:creator>WinterMist</dc:creator>
    <dc:date>2023-08-02T20:44:41Z</dc:date>
    <item>
      <title>RANKX - Unable to RANK Rows For Each Category</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3362442#M126427</link>
      <description>&lt;P&gt;Hello Community -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Frustrated with myself that I can't figure this out.&lt;/P&gt;&lt;P&gt;I've read about 10-15 related pages on forums, SQLBI etc., but still failing.&lt;/P&gt;&lt;P&gt;Seems like this should be incredibly easy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All I want to do is rank the rows for each City within a table visual based on Data[Unique ID].&lt;/P&gt;&lt;P&gt;NOTES:&lt;/P&gt;&lt;P&gt;- There can be no ties.&lt;/P&gt;&lt;P&gt;- Dummy data set is shown below.&lt;/P&gt;&lt;P&gt;- Since there is no unique column to break ties, I created the calculated column "Unique ID".&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;Desired outcome is a table visual that shows the following Excel mock-up data:&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;Regards,&lt;/P&gt;&lt;P&gt;Nathan&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 20:44:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3362442#M126427</guid>
      <dc:creator>WinterMist</dc:creator>
      <dc:date>2023-08-02T20:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: RANKX - Unable to RANK Rows For Each Category</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3364620#M126505</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="340078" data-lia-user-login="WinterMist" class="lia-mention lia-mention-user"&gt;WinterMist&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your sample data and end result first!&lt;BR /&gt;According to your description, you want to rank by the [Unique ID] group by the [City].&lt;/P&gt;
&lt;P&gt;Here are the steps you can refer to :&lt;BR /&gt;(1)If you want to create a calculated column in the table , you can use this dax:&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Column = &lt;/SPAN&gt;&lt;SPAN&gt;RANKX&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;('Table','Table'[City] = &lt;/SPAN&gt;&lt;SPAN&gt;EARLIER&lt;/SPAN&gt;&lt;SPAN&gt;('Table'[City])) , 'Table'[Unique ID] ,,&lt;/SPAN&gt;&lt;SPAN&gt;ASC&lt;/SPAN&gt;&lt;SPAN&gt; ,Dense)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;img /&gt;
&lt;P&gt;(2)If you want to create a measure , you can use this dax:&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Measure = &lt;/SPAN&gt;&lt;SPAN&gt;RANKX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CALCULATETABLE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;VALUES&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Unique ID]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;ALLEXCEPT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[City]&lt;/SPAN&gt;&lt;SPAN&gt;)) , &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Unique ID]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;ALLEXCEPT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Unique ID]&lt;/SPAN&gt;&lt;SPAN&gt;)) ,,&lt;/SPAN&gt;&lt;SPAN&gt;ASC&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;Dense&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;img /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&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&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 04 Aug 2023 02:36:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3364620#M126505</guid>
      <dc:creator>v-yueyunzh-msft</dc:creator>
      <dc:date>2023-08-04T02:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: RANKX - Unable to RANK Rows For Each Category</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3365675#M126553</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="433015" data-lia-user-login="v-yueyunzh-msft" class="lia-mention lia-mention-user"&gt;v-yueyunzh-msft&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello Aniya,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Thank you very much!&amp;nbsp; Could not have solved this without you.&amp;nbsp; This definitely works &amp;amp; I will mark it as a solution shortly.&amp;nbsp; I just want to understand a bit better.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) In general, is there a way to see the results of DAX tables within the current Filter Context (FC).&lt;/P&gt;&lt;P&gt;For example, parameter 1 (P1) is highlighted here below:&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;I understand &lt;EM&gt;in theory&lt;/EM&gt; that this CALCULATETABLE creates a single column table of&amp;nbsp;&lt;U&gt;Unique ID&lt;/U&gt; values,&amp;nbsp;&lt;/P&gt;&lt;P&gt;removing ALL filters EXCEPT the filter on &lt;U&gt;City&lt;/U&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, what if I want to actually SEE the result set of this CALCULATETABLE by itself?&lt;/P&gt;&lt;P&gt;How can I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- I cannot display it in the report (in its own separate measure) because it's a TABLE and not a SCALAR value.&lt;/P&gt;&lt;P&gt;- I cannot truly see the results in DAX Studio either, because I lose the FC of the table visual.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;As you can see below, both of the following EVALUATE statements in DAX Studio return identical results;&lt;/P&gt;&lt;P&gt;both the query &lt;EM&gt;with&lt;/EM&gt; the ALLEXCEPT clause &amp;amp; the query &lt;EM&gt;without&lt;/EM&gt; it.&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;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Is there a way to actually see the result set of this CALCULATETABLE?&lt;/P&gt;&lt;P&gt;If this is not possible, could you at least explain what the actual results of this CALCULATETABLE look like within the current FC?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) I created a second measure, based off the one you gave me; the only difference being that I separated each parameter into its own variable.&amp;nbsp; But I noticed that this does not work.&lt;/P&gt;&lt;P&gt;- Is this because my code does not use CT (Context Transition), whereas yours does?&amp;nbsp; I believe CT occurs due to CALCULATE being inside of an iterator (e.g. RANKX).&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;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again so much for your help!&lt;/P&gt;&lt;P&gt;Nathan&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 14:33:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3365675#M126553</guid>
      <dc:creator>Take3</dc:creator>
      <dc:date>2023-08-04T14:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: RANKX - Unable to RANK Rows For Each Category</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3366321#M126583</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="595785" data-lia-user-login="Take3" class="lia-mention lia-mention-user"&gt;Take3&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for marking my solution first! You are so welcome!~ For your question, this is my understand about them:&lt;/P&gt;
&lt;P&gt;(1)We cannot receive the impact of filtering context (FC) when performing corresponding Table operations in DAX STUDIO, etc., that is, we cannot view the tables generated under a certain FC. We can only simulate the tables and data that may be generated in the current filtering context (FC) through imagination.&lt;/P&gt;
&lt;P&gt;Your understanding is very correct, CALCULATETABLE creates a single column table of Unique ID values, removing ALL filters EXCEPT the filter on City .&lt;/P&gt;
&lt;P&gt;In fact, the CALCULATETABLE() function is just a function that modifies the current filtering context, similar to the CALCULATE() function, rather than modifying the filtering context of the table function.&lt;/P&gt;
&lt;P&gt;For example, when I am in [City]="Los", I will return {10147,10209,10372,10384,10432}；When I am in [City]="New York", I will return {10707,10716,10721,10727,10778}.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(2)For your second question, when you use the var in the dax code , it will not work . This is due to the "CALCULATE( SUM('Table'[Unique ID]),ALLEXCEPT('Table','Table'[Unique ID]))" can not be defined out of the rankx() function.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Because our variables are calculated during use, if defined as variables, they will be evaluated in the outer layer.&lt;/P&gt;
&lt;P&gt;Our RANKX() is a row context that performs line by line calculations. We need to include the calculated formula in this formula in order for our row context to calculate the corresponding correct result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&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&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2023 00:23:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3366321#M126583</guid>
      <dc:creator>v-yueyunzh-msft</dc:creator>
      <dc:date>2023-08-05T00:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: RANKX - Unable to RANK Rows For Each Category</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3369143#M126757</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="433015" data-lia-user-login="v-yueyunzh-msft" class="lia-mention lia-mention-user"&gt;v-yueyunzh-msft&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello Aniya,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again so much for your detailed responses.&lt;/P&gt;&lt;P&gt;Very helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nathan&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 21:26:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Unable-to-RANK-Rows-For-Each-Category/m-p/3369143#M126757</guid>
      <dc:creator>WinterMist</dc:creator>
      <dc:date>2023-08-07T21:26:33Z</dc:date>
    </item>
  </channel>
</rss>

