<?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: Rankx Quirks in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2444081#M65544</link>
    <description>&lt;P&gt;DAX can be funky&lt;/P&gt;</description>
    <pubDate>Thu, 07 Apr 2022 16:50:18 GMT</pubDate>
    <dc:creator>User5231</dc:creator>
    <dc:date>2022-04-07T16:50:18Z</dc:date>
    <item>
      <title>Rankx Quirks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2441357#M65375</link>
      <description>&lt;LI-CODE lang="markup"&gt;Sum by Category Filter Method = CALCULATE(sum('Table'[Time]), filter(ALLSELECTED('Table'),'Table'[Sub Category] = max('Table'[Sub Category])))

Sum by Sub Category Allexcept = calculate(sum('Table'[Time]), ALLEXCEPT('Table','Table'[Sub Category]))

Rank1 =
rankx(ALLSELECTED('Table'), [Sum by Category Filter Method],,DESC,Dense) //could use either measure above and works

Rank 2 = //Does Not Work
Var Sumof = calculate(sum('Table'[Time]), filter(allselected('table'), 'Table'[Sub Category] = max('Table'[Sub Category])))
Var Sumof1 = calculate(sum('Table'[Time]), ALLEXCEPT('Table','Table'[Sub Category]))
Return
rankx(ALLSELECTED('Table'[Sub Category]), Sumof1,,DESC,Dense) //sumof or sumof1 both do not work

Rank3 = rankx(ALLSELECTED('Table'), CALCULATE(sum('Table'[Time]), ALLEXCEPT('Table','Table'[Sub Category])),,DESC,Dense) /// Works

Rank4 = rankx(ALLSELECTED('Table'[Sub Category]), CALCULATE(sum('Table'[Time]), ALLEXCEPT('Table','Table'[Sub Category])),,DESC,Skip) //Works

Rank5 = rankx(ALLSELECTED('Table'[Sub Category]), CALCULATE(sum('Table'[Time]), filter(ALLSELECTED('Table'), 'Table'[Sub Category] = max('Table'[Sub Category]))),,DESC,Skip) //Doesn't Work ---- this one really perplexes me

Rank6 =
Var Table1 = SUMMARIZE(ALLSELECTED('Table'),'Table'[Sub Category], "sum", CALCULATE(sum('Table'[Time]), ALLEXCEPT('Table','Table'[Sub Category])))
Var RankedTable = ADDCOLUMNS(Table1, "Rank", rankx(Table1, [sum],,DESC))
Return
maxx(filter(RankedTable, [Sub Category] = max('Table'[Sub Category])), [Rank]) //Works --- convoluted, but this one is actually easier to apply to different uses.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone try and explain what is happenning with these RankX iterations that certian ones work and others do not. I have a simple table that I want to display the Tim summed by Sub Category, regardless of ID displayed, and then the respective rankx at the sub category level.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im assuming there is some context I am missing to explain why one method works and another doesn't.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&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>Wed, 06 Apr 2022 17:12:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2441357#M65375</guid>
      <dc:creator>User5231</dc:creator>
      <dc:date>2022-04-06T17:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Quirks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2442059#M65439</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="225652" data-lia-user-login="User5231" class="lia-mention lia-mention-user"&gt;User5231&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I think it is the context transition. Context transition does not apply to variables as they are evaluated once. This is why rank2 does not work.&lt;BR /&gt;I agreed with you on rank5 but if you think about it when refering&lt;/P&gt;&lt;LI-CODE lang="php"&gt;[Sum by Category Filter Method]&lt;/LI-CODE&gt;&lt;P&gt;it is actually translated to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;CALCULATE (
    CALCULATE (
        SUM ( 'Table'[Time] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Sub Category] = MAX ( 'Table'[Sub Category] )
        )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;As the engine wraps any measure referenced in any kind of calculation with CALCULATE.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just a thought. you may try and confirm.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 03:44:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2442059#M65439</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-07T03:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Quirks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2443714#M65514</link>
      <description>&lt;P&gt;Thanks! I think you explained it well enough... and sure enough wrapping that expression for Rank5 in a calculate does indeed make it work. That is interesting though that the Allexcept version does not need that. Any ideas on why that is the case?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 14:10:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2443714#M65514</guid>
      <dc:creator>User5231</dc:creator>
      <dc:date>2022-04-07T14:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Quirks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2444031#M65542</link>
      <description>&lt;P&gt;Why would the ALLEXCEPT be an exception?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 16:11:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2444031#M65542</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-07T16:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Quirks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2444081#M65544</link>
      <description>&lt;P&gt;DAX can be funky&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 16:50:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2444081#M65544</guid>
      <dc:creator>User5231</dc:creator>
      <dc:date>2022-04-07T16:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Quirks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2444116#M65547</link>
      <description>&lt;P&gt;Indeed&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 17:19:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Quirks/m-p/2444116#M65547</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-07T17:19:14Z</dc:date>
    </item>
  </channel>
</rss>

