<?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 with multiple conditions/columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-with-multiple-conditions-columns/m-p/3163925#M113712</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="414682" data-lia-user-login="yellow43" class="lia-mention lia-mention-user"&gt;yellow43&lt;/a&gt;&amp;nbsp;OK, post sample data as text in a table. I'm not hand-typing all that data. You might have better luck with this though:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Ranking 2 = 
  VAR __code = MAX('Table2'[code]
  VAR __country = MAX('Table2'[country])
  VAR __brand = MAX('Table2'[brand])
  VAR __Table = FILTER(ALL('Table2'),Table2[code]=__code &amp;amp;&amp;amp; Table2[country] = __coutnry &amp;amp;&amp;amp; Table2[brand] = __brand)
  VAR __Result = RANKX(__Table,CALCULATE(SUM(Table2[QTY])),,ASC)
RETURN
  __Result&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 30 Mar 2023 16:16:55 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2023-03-30T16:16:55Z</dc:date>
    <item>
      <title>Rank with multiple conditions/columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-with-multiple-conditions-columns/m-p/3163733#M113704</link>
      <description>&lt;P&gt;I have the below data and I need to have a ranking with multiple conditions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; same code, same country, different brand - first criteria is brand with highiest QTY&lt;/P&gt;&lt;P&gt;2. if there is a tie in QTY - 2nd criteria should be AVG SALES&lt;/P&gt;&lt;P&gt;3. QTY with 0 (zero) and AVG SALES with blank should not be considered&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following formula:&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;Rank measure: = 
IF (
    HASONEVALUE ( 'Table2'[country] ),
    CALCULATE (
        COUNTROWS ( 'Table2' ),
        WINDOW (
            1,
            ABS,
            4,
            REL,
            SUMMARIZE (
                ALL ( 'Table2'),
                'Table2'[country],
                'Table2'[brand],
                'Table2'[QTY], 'Table2'[AVG SALES]
                
            ),
            ORDERBY ( 'Table2'[QTY], ASC, 'Table2'[AVG SALES], ASC ),
            KEEP,
            PARTITIONBY ( 'Table2'[country])
        )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But shows ranking like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;And desired result should be:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 14:49:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-with-multiple-conditions-columns/m-p/3163733#M113704</guid>
      <dc:creator>yellow43</dc:creator>
      <dc:date>2023-03-30T14:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Rank with multiple conditions/columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-with-multiple-conditions-columns/m-p/3163745#M113706</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="414682" data-lia-user-login="yellow43" class="lia-mention lia-mention-user"&gt;yellow43&lt;/a&gt;&amp;nbsp;If you post sample data as text can be more specific. Why aren't you using RANKX?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/To-Bleep-with-RANKX/m-p/1042520#M452" target="_blank"&gt;To *Bleep* with RANKX! - Microsoft Power BI Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;div data-video-id="https://youtu.be/DXTzHyqNC4A" data-video-remote-vid="https://youtu.be/DXTzHyqNC4A" class="lia-video-container lia-media-is-center lia-media-size-medium"&gt;&lt;iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FDXTzHyqNC4A%3Ffeature%3Doembed&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DDXTzHyqNC4A&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FDXTzHyqNC4A%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" allowfullscreen="" style="max-width: 100%"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 14:52:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-with-multiple-conditions-columns/m-p/3163745#M113706</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-03-30T14:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rank with multiple conditions/columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-with-multiple-conditions-columns/m-p/3163784#M113707</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;i have already tried:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Ranking 2 = 
RANKX(FILTER(ALL('Table2'),Table2[code]=MAX(Table2[code])&amp;amp;&amp;amp;Table2[country] = MAX(Table2[country]) &amp;amp;&amp;amp; Table2[brand] = MAX(Table2[brand])),CALCULATE(SUM(Table2[QTY])),,ASC)&lt;/LI-CODE&gt;&lt;P&gt;and it's not working&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 15:12:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-with-multiple-conditions-columns/m-p/3163784#M113707</guid>
      <dc:creator>yellow43</dc:creator>
      <dc:date>2023-03-30T15:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rank with multiple conditions/columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-with-multiple-conditions-columns/m-p/3163925#M113712</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="414682" data-lia-user-login="yellow43" class="lia-mention lia-mention-user"&gt;yellow43&lt;/a&gt;&amp;nbsp;OK, post sample data as text in a table. I'm not hand-typing all that data. You might have better luck with this though:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Ranking 2 = 
  VAR __code = MAX('Table2'[code]
  VAR __country = MAX('Table2'[country])
  VAR __brand = MAX('Table2'[brand])
  VAR __Table = FILTER(ALL('Table2'),Table2[code]=__code &amp;amp;&amp;amp; Table2[country] = __coutnry &amp;amp;&amp;amp; Table2[brand] = __brand)
  VAR __Result = RANKX(__Table,CALCULATE(SUM(Table2[QTY])),,ASC)
RETURN
  __Result&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 30 Mar 2023 16:16:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rank-with-multiple-conditions-columns/m-p/3163925#M113712</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-03-30T16:16:55Z</dc:date>
    </item>
  </channel>
</rss>

