<?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: Rank function on selected dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4028475#M159166</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I do not know how your semantic model looks like, but I tried to create a sample pbix file like below.&lt;/P&gt;
&lt;P&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;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/rank-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank"&gt;RANK function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/window-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank"&gt;WINDOW function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales: = 
SUM(sales[sales])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Rank sales: = 
RANK (
    SKIP,
    SUMMARIZE ( ALLSELECTED ( sales ), sales_team[sales_team] ),
    ORDERBY ( CALCULATE ( SUM ( sales[sales] ) ), DESC )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales rank top5 and bottom3 = 
VAR _top5 =
    WINDOW (
        1,
        ABS,
        5,
        ABS,
        SUMMARIZE ( ALLSELECTED ( sales ), sales_team[sales_team] ),
        ORDERBY ( CALCULATE ( SUM ( sales[sales] ) ), DESC )
    )
VAR _bottom3 =
    WINDOW (
        1,
        ABS,
        3,
        ABS,
        SUMMARIZE ( ALLSELECTED ( sales ), sales_team[sales_team] ),
        ORDERBY ( CALCULATE ( SUM ( sales[sales] ) ), ASC )
    )
VAR _teamlist =
    UNION ( _top5, _bottom3 )
RETURN
    CALCULATE (
        SUM ( sales[sales] ),
        KEEPFILTERS ( sales_team[sales_team] IN _teamlist )
    )&lt;/LI-CODE&gt;</description>
    <pubDate>Sun, 07 Jul 2024 05:13:16 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2024-07-07T05:13:16Z</dc:date>
    <item>
      <title>Rank function on selected dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4027427#M159152</link>
      <description>&lt;P&gt;We need to apply conditional formatting to identify the top 5 and bottom 3 values in a dataset, based on user-selected fiscal periods. The selection can include non-continuous fiscal periods, and the ranking should be recalculated to ignore any periods that are not selected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Users can select any combination of fiscal periods. This selection can include continuous periods (e.g., 2024 P05, 2024 P04, 2024 P03) or non-continuous periods (e.g., 2024 P04, 2023 P11, 2022 P03).&lt;/P&gt;&lt;P&gt;The ranking should dynamically adjust based on the selected periods. For example, if the user selects 2024 P05, 2023 P05, and 2022 P05, the ranks should be recalculated as 1, 2, and 3 based on the values for these periods alone, not the entire dataset.&amp;nbsp;This ranking should ensure that the top 5 and bottom 3 values are identified correctly based on the user's selection.&lt;/P&gt;&lt;P&gt;To represent the top 5 and bottom 3 values I will use conditional formatting, so after ranking the periods correctly, it should return 1 for the top 5 values and 2 for the bottom 3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The fiscal periods are stored in the Calendar[Year Period] column.&lt;/P&gt;&lt;P&gt;The format of fiscal periods is YYYY PXX, for example, 2024 P05 for the 5th period of the year 2024.&lt;/P&gt;&lt;P&gt;We have a Fiscal Calendar Table that has columns for Year, Beginning Date, Ending Date and Period Number.&lt;BR /&gt;We have measures for all KPIs.&lt;BR /&gt;&lt;BR /&gt;Is this possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 16:33:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4027427#M159152</guid>
      <dc:creator>llealsantos</dc:creator>
      <dc:date>2024-07-05T16:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rank function on selected dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4028238#M159153</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="660356" data-lia-user-login="llealsantos" class="lia-mention lia-mention-user"&gt;llealsantos&lt;/a&gt;&amp;nbsp;,&amp;nbsp;remember to adhere to the decorum of the Community Forum when asking a question.&lt;BR /&gt;&lt;BR /&gt;Please provide your work-in-progress Power BI Desktop file (with sensitive information removed) that covers your issue or question completely in a usable format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523/highlight/true#M607150" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523/highlight/true#M607150&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This allows members of the Forum to assess the state of the model, report layer, relationships, and any DAX applied.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2024 17:43:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4028238#M159153</guid>
      <dc:creator>foodd</dc:creator>
      <dc:date>2024-07-06T17:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Rank function on selected dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4028469#M159164</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;please check the rankx function what I have used on the dataset.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Please check the final output.&lt;BR /&gt;&lt;BR /&gt;If you think that this helps you then accept this as your solution.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2024 04:55:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4028469#M159164</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-07T04:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: Rank function on selected dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4028475#M159166</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I do not know how your semantic model looks like, but I tried to create a sample pbix file like below.&lt;/P&gt;
&lt;P&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;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/rank-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank"&gt;RANK function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/window-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank"&gt;WINDOW function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales: = 
SUM(sales[sales])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Rank sales: = 
RANK (
    SKIP,
    SUMMARIZE ( ALLSELECTED ( sales ), sales_team[sales_team] ),
    ORDERBY ( CALCULATE ( SUM ( sales[sales] ) ), DESC )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales rank top5 and bottom3 = 
VAR _top5 =
    WINDOW (
        1,
        ABS,
        5,
        ABS,
        SUMMARIZE ( ALLSELECTED ( sales ), sales_team[sales_team] ),
        ORDERBY ( CALCULATE ( SUM ( sales[sales] ) ), DESC )
    )
VAR _bottom3 =
    WINDOW (
        1,
        ABS,
        3,
        ABS,
        SUMMARIZE ( ALLSELECTED ( sales ), sales_team[sales_team] ),
        ORDERBY ( CALCULATE ( SUM ( sales[sales] ) ), ASC )
    )
VAR _teamlist =
    UNION ( _top5, _bottom3 )
RETURN
    CALCULATE (
        SUM ( sales[sales] ),
        KEEPFILTERS ( sales_team[sales_team] IN _teamlist )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 07 Jul 2024 05:13:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4028475#M159166</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-07-07T05:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Rank function on selected dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4029810#M159303</link>
      <description>&lt;P&gt;Thank you!! It was that ALLSELECTED that was missing&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 09:13:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4029810#M159303</guid>
      <dc:creator>llealsantos</dc:creator>
      <dc:date>2024-07-08T09:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Rank function on selected dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4029812#M159304</link>
      <description>&lt;P&gt;Thank you so much!! I was missing that ALLSELECTED&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 09:13:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4029812#M159304</guid>
      <dc:creator>llealsantos</dc:creator>
      <dc:date>2024-07-08T09:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Rank function on selected dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4029818#M159305</link>
      <description>&lt;P&gt;Unfortunately, I don't have time to do all that. Thank you for your useful reply.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 09:15:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-function-on-selected-dates/m-p/4029818#M159305</guid>
      <dc:creator>llealsantos</dc:creator>
      <dc:date>2024-07-08T09:15:56Z</dc:date>
    </item>
  </channel>
</rss>

