<?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: Create a new column with Rank with Multiple Columns and group by in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3660697#M141850</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="446607" data-lia-user-login="DallasBaba" class="lia-mention lia-mention-user"&gt;DallasBaba&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Big Help!&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jan 2024 14:29:43 GMT</pubDate>
    <dc:creator>yellow43</dc:creator>
    <dc:date>2024-01-25T14:29:43Z</dc:date>
    <item>
      <title>Create a new column with Rank with Multiple Columns and group by</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3657713#M141723</link>
      <description>&lt;P&gt;Hi Fabric Community,&lt;/P&gt;&lt;P&gt;I need help with following:&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Customer&lt;/TD&gt;&lt;TD&gt;country&lt;/TD&gt;&lt;TD&gt;product&lt;/TD&gt;&lt;TD&gt;qty&lt;/TD&gt;&lt;TD&gt;AVG sales&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ALEX&lt;/TD&gt;&lt;TD&gt;Germany&lt;/TD&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&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&lt;/TD&gt;&lt;TD&gt;country&lt;/TD&gt;&lt;TD&gt;product&lt;/TD&gt;&lt;TD&gt;qty&lt;/TD&gt;&lt;TD&gt;AVG sales&lt;/TD&gt;&lt;TD&gt;Rank measure:&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ALEX&lt;/TD&gt;&lt;TD&gt;Spain&lt;/TD&gt;&lt;TD&gt;C3&lt;/TD&gt;&lt;TD&gt;55&lt;/TD&gt;&lt;TD&gt;680,00 €&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ALEX&lt;/TD&gt;&lt;TD&gt;Spain&lt;/TD&gt;&lt;TD&gt;A2&lt;/TD&gt;&lt;TD&gt;72&lt;/TD&gt;&lt;TD&gt;100,00 €&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ALEX&lt;/TD&gt;&lt;TD&gt;Spain&lt;/TD&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;420&lt;/TD&gt;&lt;TD&gt;520,00 €&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Conditions:&lt;/P&gt;&lt;P&gt;1. same customer, same country, different product should rank by qty (1st criteria) and then by avg_sales (2nd criteria)&lt;/P&gt;&lt;P&gt;2. ignore all null values and zero values in columns [qty] and [AVG sales]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have already following measure:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rank measure: =
IF (
HASONEVALUE ( 'Table'[country] ),
CALCULATE (
COUNTROWS ( 'Table' ),
WINDOW (
1,
ABS,
4,
REL,
SUMMARIZE (
ALL ( 'Table'),
'Table'[country],
'Table'[product],
'Table'[qty], 'Table'[AVG Sales]

),
ORDERBY ( 'Table'[qty], ASC, 'Table'[AVG Sales], ASC ),
DEFAULT,
PARTITIONBY ( 'Table'[country])
)
)
)&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;&lt;/P&gt;&lt;P&gt;But is not ignoring null and zero values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 17:03:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3657713#M141723</guid>
      <dc:creator>yellow43</dc:creator>
      <dc:date>2024-01-24T17:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column with Rank with Multiple Columns and group by</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3658846#M141770</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;t&lt;SPAN&gt;o create a new column with rank based on multiple columns and group by, you can use the following DAX formula:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rank measure = 
IF (
    HASONEVALUE ( 'Table'[country] ),
    CALCULATE (
        COUNTROWS ( 'Table' ),
        WINDOW (
            1,
            ABS,
            4,
            REL,
            SUMMARIZE (
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[qty] &amp;gt; 0 &amp;amp;&amp;amp; 'Table'[AVG sales] &amp;gt; 0
                ),
                'Table'[country],
                'Table'[product],
                'Table'[qty],
                'Table'[AVG sales]
            ),
            ORDERBY (
                'Table'[qty],
                ASC,
                'Table'[AVG sales],
                ASC
            ),
            DEFAULT,
            PARTITIONBY ( 'Table'[country] )
        )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This formula will ignore all null and zero values in columns&amp;nbsp;&lt;STRONG&gt;[qty]&lt;/STRONG&gt; and&lt;STRONG&gt;&amp;nbsp;[AVG sales].&lt;/STRONG&gt;&amp;nbsp;It will rank the rows based on the criteria you specified: same customer, same country, different product should rank by&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;qty&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(1st criteria) and then by&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;AVG sales&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;(2nd criteria).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that the formula is case-sensitive and the column names must match exactly with the ones in your table. Also, make sure to replace&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;'Table'&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;with the name of your table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Let me know if this works for you.&amp;nbsp;@ me in replies, or I'll lose your thread!!!&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;BR /&gt;&lt;U&gt;Note:&lt;/U&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If this post is helpful, please mark it as the&amp;nbsp;&lt;STRONG&gt;solution&lt;/STRONG&gt;&amp;nbsp;to help others find it easily. Also, if my answers contribute to a solution, show your appreciation by giving it a&amp;nbsp;&lt;STRONG&gt;thumbs up&lt;/STRONG&gt;!&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 25 Jan 2024 05:48:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3658846#M141770</guid>
      <dc:creator>DallasBaba</dc:creator>
      <dc:date>2024-01-25T05:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column with Rank with Multiple Columns and group by</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3659510#M141804</link>
      <description>&lt;P&gt;Hi &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;,&lt;/P&gt;
&lt;P&gt;If I understand correctly, the issue is that you want to create a new column with Rank. Please &lt;SPAN&gt;try the following methods and check if they can solve your problem:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1.Create the simple table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2.Create a new measure to rank. Enter the following DAX formula.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;00_Rank = if(SUM('Table'[AVG sales])&amp;gt;0, RANKX(FILTER(ALLSELECTED('Table'),'Table'[qty]&amp;gt;0),CALCULATE(SUM('Table'[AVG sales])),,ASC,Dense) )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3.Drag the measure to the table visual.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;4.The result is shown below.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 09:15:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3659510#M141804</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-25T09:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column with Rank with Multiple Columns and group by</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3660697#M141850</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="446607" data-lia-user-login="DallasBaba" class="lia-mention lia-mention-user"&gt;DallasBaba&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Big Help!&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 14:29:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3660697#M141850</guid>
      <dc:creator>yellow43</dc:creator>
      <dc:date>2024-01-25T14:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column with Rank with Multiple Columns and group by</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3660871#M141861</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;I am happy to know it works.&amp;nbsp; Kindly&amp;nbsp;@ me with any future needs around Power BI and Fabric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please give it a kudos by clicking the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Thumbs Up&lt;/STRONG&gt;! It goes a long way to helping others find this solution&amp;nbsp;quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 15:45:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-new-column-with-Rank-with-Multiple-Columns-and-group-by/m-p/3660871#M141861</guid>
      <dc:creator>DallasBaba</dc:creator>
      <dc:date>2024-01-25T15:45:11Z</dc:date>
    </item>
  </channel>
</rss>

