<?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 for the last 12 months, but single month selected in slicer in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-for-the-last-12-months-but-single-month-selected-in-slicer/m-p/1633644#M33135</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255504" data-lia-user-login="N_R_000" class="lia-mention lia-mention-user"&gt;N_R_000&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're on the right track. I would write the measure like this:&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;Monthly Sales Rank =
VAR SumOfSales = [Sum of Sales]
VAR Result =
    CALCULATE (
        RANKX (
            VALUES ( 'Calendar'[Month Year] ),
            [Sum of Sales], // Evaluated for each Month Year
            SumOfSales, // Fixed value for month filtered on slicer
            DESC,
            DENSE
        ),
        // 12 months ending today.
        //You may want to tweak to ensure complete calendar months etc
        DATESINPERIOD ( 'Calendar'[Date], TODAY (), -12, MONTH )
    )
RETURN
    Result
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The SumOfSales variable stores the sales value for the month selected on the slicer.&lt;/P&gt;
&lt;P&gt;Then the RANKX calculation is wrapped in a CALCULATE which changes the date filter to 12 months ending today.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this give you the expected result?&lt;/P&gt;</description>
    <pubDate>Sun, 31 Jan 2021 02:06:28 GMT</pubDate>
    <dc:creator>OwenAuger</dc:creator>
    <dc:date>2021-01-31T02:06:28Z</dc:date>
    <item>
      <title>RANKX for the last 12 months, but single month selected in slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-for-the-last-12-months-but-single-month-selected-in-slicer/m-p/1633459#M33131</link>
      <description>&lt;P&gt;I'd like to show the rank of a months sales based on only the previous 12 months.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The kicker is that there's a single selection 'Month Year' slicer in use here.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I just need a way to expand the RANKX dates to the previous 12 months&amp;nbsp;(previous based from today, not the selected month).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't use ALL('Calendar'[dates]) because there is 3 years worth sales of data in total and I'm only interested in the last 1 year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would something like this do the trick? Worth mentioning that I need this value to go in a standalone Card, not a monthly grouped table.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Monthly Sales Rank = RANKX(FILTER('Calendar', &amp;lt;PREVIOUS 12 MONTHS?&amp;gt; ), CALCULATE([Sum Of Sales]),,DESC, DENSE)&lt;/LI-CODE&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;</description>
      <pubDate>Sat, 30 Jan 2021 20:36:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-for-the-last-12-months-but-single-month-selected-in-slicer/m-p/1633459#M33131</guid>
      <dc:creator>N_R_000</dc:creator>
      <dc:date>2021-01-30T20:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: RANKX for the last 12 months, but single month selected in slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-for-the-last-12-months-but-single-month-selected-in-slicer/m-p/1633644#M33135</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255504" data-lia-user-login="N_R_000" class="lia-mention lia-mention-user"&gt;N_R_000&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're on the right track. I would write the measure like this:&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;Monthly Sales Rank =
VAR SumOfSales = [Sum of Sales]
VAR Result =
    CALCULATE (
        RANKX (
            VALUES ( 'Calendar'[Month Year] ),
            [Sum of Sales], // Evaluated for each Month Year
            SumOfSales, // Fixed value for month filtered on slicer
            DESC,
            DENSE
        ),
        // 12 months ending today.
        //You may want to tweak to ensure complete calendar months etc
        DATESINPERIOD ( 'Calendar'[Date], TODAY (), -12, MONTH )
    )
RETURN
    Result
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The SumOfSales variable stores the sales value for the month selected on the slicer.&lt;/P&gt;
&lt;P&gt;Then the RANKX calculation is wrapped in a CALCULATE which changes the date filter to 12 months ending today.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this give you the expected result?&lt;/P&gt;</description>
      <pubDate>Sun, 31 Jan 2021 02:06:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-for-the-last-12-months-but-single-month-selected-in-slicer/m-p/1633644#M33135</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2021-01-31T02:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: RANKX for the last 12 months, but single month selected in slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-for-the-last-12-months-but-single-month-selected-in-slicer/m-p/1633933#M33145</link>
      <description>&lt;P&gt;Hi Owen,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the detailed explaination.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just made a small tweak to DATESINPERIOD to swap TODAY() for a 'EndOfDateRange' measure and that give me the full months I need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your help!&lt;/P&gt;</description>
      <pubDate>Sun, 31 Jan 2021 21:17:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-for-the-last-12-months-but-single-month-selected-in-slicer/m-p/1633933#M33145</guid>
      <dc:creator>N_R_000</dc:creator>
      <dc:date>2021-01-31T21:17:54Z</dc:date>
    </item>
  </channel>
</rss>

