<?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: Ranking with multiple rows and drilldown in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3517257#M135060</link>
    <description>&lt;P&gt;Hello &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your answer ! It is indeed working in the PBI you linked but sadly it doesn't work on mine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've checked and I don't have any sort-by columns in Invoices List, the code in entering conditions as expected but somehow, the rank part in the REF scope isn't working and I still have 1 everywhere...&lt;BR /&gt;&lt;BR /&gt;I also know that I have blanks in my Nb samples collected. But it shouldn't have any impacts as I filtered the result to have only those greater than 0 and in my Total Samples collected measure, I make sure that I don't consider BLANK().&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Samples collected = 
    CALCULATE(
        SUM('Invoices List'[Nb samples collected]),
        FILTER('Invoices List','Invoices List'[Nb samples collected] &amp;lt;&amp;gt; BLANK())
    )&lt;/LI-CODE&gt;&lt;P&gt;Do you have another idea ?&lt;/P&gt;</description>
    <pubDate>Mon, 06 Nov 2023 08:27:44 GMT</pubDate>
    <dc:creator>VBLOT</dc:creator>
    <dc:date>2023-11-06T08:27:44Z</dc:date>
    <item>
      <title>Ranking with multiple rows and drilldown</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3514929#M134920</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried for many hours and differents ways but I can't manage to rank my matrix.&lt;BR /&gt;&lt;BR /&gt;I have two lines in my Matrix :&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see in the screen bellow, I want to rank REF (higher level) separately from Line Designation (sublevel)&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;With ISINSCOPE function, Im able to see that to calculate REF ranking I need to have REFInScope = True &amp;amp;&amp;amp; LineInScope = False&lt;BR /&gt;&lt;BR /&gt;But with that in mind I somehow can't manage to do the right calculation (Ranking works when I have only 1 line)&lt;BR /&gt;&lt;BR /&gt;See one of the DAX measure I've done :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rank = 
VAR IsLineInScope = ISINSCOPE('Invoices List'[Line Designation])
VAR IsREFInScope = ISINSCOPE('Invoices List'[REF])

RETURN
    IF(
        IsLineInScope &amp;amp;&amp;amp; IsREFInScope,
        RANKX(ALLSELECTED('Invoices List'[Line Designation]), [Total Samples collected]),
        IF(
            NOT IsLineInScope &amp;amp;&amp;amp; IsREFInScope,
            RANKX(ALLSELECTED('Invoices List'[REF]), [Total Samples collected]),
            BLANK()
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;Can you please help me? I've tried like 50 differents measures, watch videos and nothing works. I also tried with RANK and not RANKX....&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 16:51:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3514929#M134920</guid>
      <dc:creator>VBLOT</dc:creator>
      <dc:date>2023-11-03T16:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Ranking with multiple rows and drilldown</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3515374#M134941</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="523111" data-lia-user-login="VBLOT" class="lia-mention lia-mention-user"&gt;VBLOT&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your logic is essentially correct!&lt;/P&gt;
&lt;P&gt;In fact your measure works fine in a test PBIX I created, as long as [Total Samples Collected] always has positive values (example in attached PBIX).&lt;/P&gt;
&lt;P&gt;However, since it wasn't working correctly for you, it's possible that there is a complication in your model. Are there any sort-by columns defined by any chance?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A more robust way I would suggest writing this measure is using the RANK function, since we can specify partitioning.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Rank = 
VAR IsLineInScope =
    ISINSCOPE ( 'Invoices List'[Line Designation] )
VAR IsREFInScope = ISINSCOPE ( 'Invoices List'[REF] )
VAR Result =
    SWITCH (
        TRUE ( ),
        IsLineInScope &amp;amp;&amp;amp; IsREFInScope,
            RANK (
                DENSE,
                CALCULATETABLE (
                    SUMMARIZE (
                        'Invoices List',
                        'Invoices List'[Line Designation],
                        'Invoices List'[REF]
                    ),
                    ALLSELECTED ( )
                ),
                ORDERBY ( [Total Samples Collected], DESC ),
                PARTITIONBY ( 'Invoices List'[REF] )
            ),
        NOT IsLineInScope &amp;amp;&amp;amp; IsREFInScope,
            RANK (
                DENSE,
                CALCULATETABLE (
                    SUMMARIZE ( 'Invoices List', 'Invoices List'[REF] ),
                    ALLSELECTED ( )
                ),
                ORDERBY ( [Total Samples Collected], DESC )
            )
    )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PBIX attached for reference&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Rank Original&lt;/STRONG&gt; is your posted measure.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Rank&lt;/STRONG&gt; is updated measures.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2023 00:27:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3515374#M134941</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-11-04T00:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Ranking with multiple rows and drilldown</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3517257#M135060</link>
      <description>&lt;P&gt;Hello &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your answer ! It is indeed working in the PBI you linked but sadly it doesn't work on mine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've checked and I don't have any sort-by columns in Invoices List, the code in entering conditions as expected but somehow, the rank part in the REF scope isn't working and I still have 1 everywhere...&lt;BR /&gt;&lt;BR /&gt;I also know that I have blanks in my Nb samples collected. But it shouldn't have any impacts as I filtered the result to have only those greater than 0 and in my Total Samples collected measure, I make sure that I don't consider BLANK().&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Samples collected = 
    CALCULATE(
        SUM('Invoices List'[Nb samples collected]),
        FILTER('Invoices List','Invoices List'[Nb samples collected] &amp;lt;&amp;gt; BLANK())
    )&lt;/LI-CODE&gt;&lt;P&gt;Do you have another idea ?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 08:27:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3517257#M135060</guid>
      <dc:creator>VBLOT</dc:creator>
      <dc:date>2023-11-06T08:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Ranking with multiple rows and drilldown</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3517424#M135069</link>
      <description>&lt;P&gt;Hi again&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="523111" data-lia-user-login="VBLOT" class="lia-mention lia-mention-user"&gt;VBLOT&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you share a sanitised PBIX file that exhibits the problem? Even filtered down to a couple of REF values.&lt;/P&gt;
&lt;P&gt;(share a link to Google Drive / OneDrive etc).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From what you've posted, it should be working, but there must be some particular feature of your data model that is causing this.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 09:59:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3517424#M135069</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-11-06T09:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Ranking with multiple rows and drilldown</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3517465#M135072</link>
      <description>&lt;P&gt;Hi again &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find a sanitised file here :&lt;BR /&gt;&lt;A href="https://norishare.com/P9TDkeS9yJF" target="_self"&gt;https://norishare.com/P9TDkeS9yJF&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 10:16:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3517465#M135072</guid>
      <dc:creator>VBLOT</dc:creator>
      <dc:date>2023-11-06T10:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Ranking with multiple rows and drilldown</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3519564#M135185</link>
      <description>&lt;P&gt;Hi again&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="523111" data-lia-user-login="VBLOT" class="lia-mention lia-mention-user"&gt;VBLOT&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much for the file! That made it a lot easier to debug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems that the problem actually relates to how the visual level filter &lt;STRONG&gt;"Sum of Nb samples collected &amp;gt; 0"&lt;/STRONG&gt; interacts with the ALLSELECTED () modifier used to produce the table for ranking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A safer way to write the measure is below (see attached PBIX). Actually in &lt;A href="https://www.sqlbi.com/whitepapers/windows-functions-in-dax/" target="_blank" rel="noopener"&gt;their Whitepaper&lt;/A&gt;, SQLBI recommend this general approach of adding column(s) to the "relation" argument of window functions.&lt;/P&gt;
&lt;P&gt;I might have to get back to you with an explanation of why it works when I've analyzed further.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Rank FIX = 
VAR IsLineInScope = ISINSCOPE ( 'Invoices List'[Line Designation] )
VAR IsREFInScope = ISINSCOPE ( 'Invoices List'[REF] )
VAR Result =
    SWITCH (
        TRUE ( ),
        IsLineInScope &amp;amp;&amp;amp; IsREFInScope,
            RANK (
                DENSE,
                CALCULATETABLE (
                    ADDCOLUMNS (
                        SUMMARIZE (
                            'Invoices List',
                            'Invoices List'[Line Designation],
                            'Invoices List'[REF]
                        ),
                        "@TotalSamples", [Total Samples collected]
                    ),
                    ALLSELECTED ()
                ),
                ORDERBY ( [@TotalSamples], DESC ), ,
                PARTITIONBY('Invoices List'[REF])
               
            ),
        NOT IsLineInScope &amp;amp;&amp;amp; IsREFInScope,
            RANK (
                DENSE,
                CALCULATETABLE (
                    ADDCOLUMNS (
                        SUMMARIZE ( 'Invoices List', 'Invoices List'[REF] ),
                        "@TotalSamples", [Total Samples collected]
                    ),
                    ALLSELECTED ( )
                ),
                ORDERBY ( [@TotalSamples], DESC )
            )
    )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 10:03:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Ranking-with-multiple-rows-and-drilldown/m-p/3519564#M135185</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-11-07T10:03:36Z</dc:date>
    </item>
  </channel>
</rss>

