<?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: Dynamic Ranking for legend. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663337#M141964</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="681124" data-lia-user-login="Swam80" class="lia-mention lia-mention-user"&gt;Swam80&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;you can use the RANKX function. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;First, create a new measure that calculates the metric value for each customer.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Order Count per Customer = CALCULATE([Order Count], ALLSELECTED(Customers))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;Create another measure that ranks the customers based on the selected metric.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Customer Rank = RANKX(ALLSELECTED(Customers), [Order Count per Customer], , DESC)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Create another measure that filters the data based on the selected metric and the top N customers. For example, if you want to filter the data based on the order count and the top 10 customers, you can create a measure like this&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top N Customers Order Count = CALCULATE([Order Count], TOPN(10, ALLSELECTED(Customers), [Order Count per Customer]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a line chart with the date table on the x-axis, the selected metric on the y-axis, and the customer name on the legend. Then, add a visual-level filter to the chart that filters the data based on the customer rank and the top N customers.&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>Fri, 26 Jan 2024 19:38:17 GMT</pubDate>
    <dc:creator>DallasBaba</dc:creator>
    <dc:date>2024-01-26T19:38:17Z</dc:date>
    <item>
      <title>Dynamic Ranking for legend.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663308#M141962</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have been working on a powerbi project and I am new to this so just exploring. I have orders table, customers table,date table along with few other tables and I have created measures for metrics like Order count, Order quantity, LIFR%,VOFR%,OTIF%, etc. What I want to do is, plot a linechart of every metric with time (from date table) but only top N customers.&amp;nbsp;&lt;BR /&gt;So I have done this till now. Basically I created a table with metrics name and then&amp;nbsp;&lt;SPAN&gt;Selected_Metric_Value will return the metric value when i select it in slicer. I have tried using RANKX but the lineplot does not show the legend of customer names properly.&lt;BR /&gt;&lt;/SPAN&gt;For eg : If I select LIFR% on the slicer, I want the linechart to have top N customers lines vs timeframe. Then if I select Order count then I want the plot to dynamically change the data and legend both.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;MetricsTable = &lt;/SPAN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gt;&lt;SPAN&gt;[Metric]&lt;/SPAN&gt;&lt;SPAN&gt;) == &lt;/SPAN&gt;&lt;SPAN&gt;"Order Lines Count"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[Total_order_lines]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MetricsTable&lt;/SPAN&gt;&lt;SPAN&gt;[Metric]&lt;/SPAN&gt;&lt;SPAN&gt;) == &lt;/SPAN&gt;&lt;SPAN&gt;"Order Quantity"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[Total_order_quantity]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MetricsTable&lt;/SPAN&gt;&lt;SPAN&gt;[Metric]&lt;/SPAN&gt;&lt;SPAN&gt;) == &lt;/SPAN&gt;&lt;SPAN&gt;"LIFR%"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[LIFR%]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MetricsTable&lt;/SPAN&gt;&lt;SPAN&gt;[Metric]&lt;/SPAN&gt;&lt;SPAN&gt;) == &lt;/SPAN&gt;&lt;SPAN&gt;"VOFR"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[VOFR%]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MetricsTable&lt;/SPAN&gt;&lt;SPAN&gt;[Metric]&lt;/SPAN&gt;&lt;SPAN&gt;) == &lt;/SPAN&gt;&lt;SPAN&gt;"OTIF%"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[OTIF%]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;BLANK&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 26 Jan 2024 19:09:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663308#M141962</guid>
      <dc:creator>Swam80</dc:creator>
      <dc:date>2024-01-26T19:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Ranking for legend.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663337#M141964</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="681124" data-lia-user-login="Swam80" class="lia-mention lia-mention-user"&gt;Swam80&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;you can use the RANKX function. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;First, create a new measure that calculates the metric value for each customer.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Order Count per Customer = CALCULATE([Order Count], ALLSELECTED(Customers))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;Create another measure that ranks the customers based on the selected metric.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Customer Rank = RANKX(ALLSELECTED(Customers), [Order Count per Customer], , DESC)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Create another measure that filters the data based on the selected metric and the top N customers. For example, if you want to filter the data based on the order count and the top 10 customers, you can create a measure like this&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top N Customers Order Count = CALCULATE([Order Count], TOPN(10, ALLSELECTED(Customers), [Order Count per Customer]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a line chart with the date table on the x-axis, the selected metric on the y-axis, and the customer name on the legend. Then, add a visual-level filter to the chart that filters the data based on the customer rank and the top N customers.&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>Fri, 26 Jan 2024 19:38:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663337#M141964</guid>
      <dc:creator>DallasBaba</dc:creator>
      <dc:date>2024-01-26T19:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Ranking for legend.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663345#M141965</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;the thing is , I will have to do it for every metric.&lt;BR /&gt;I have one measure&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Top_Ranks = &lt;/SPAN&gt;&lt;SPAN&gt;RANKX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;dim_customers&lt;/SPAN&gt;&lt;SPAN&gt;[customer_name]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;[Selected_Metric_Value]&lt;/SPAN&gt;&lt;SPAN&gt;, , &lt;/SPAN&gt;&lt;SPAN&gt;DESC&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;Dense&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;So this will take whatever metric i selected in the slicer and rank it. I am lost after this.&amp;nbsp;&lt;BR /&gt;Because if I use a table visual, with values as top_ranks and rows as customer name. it gives proper ranks for every customer. But in lineplot, when I use customer name in the legend, it messes up.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 26 Jan 2024 19:44:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663345#M141965</guid>
      <dc:creator>Swam80</dc:creator>
      <dc:date>2024-01-26T19:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Ranking for legend.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663398#M141969</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="681124" data-lia-user-login="Swam80" class="lia-mention lia-mention-user"&gt;Swam80&lt;/a&gt;&amp;nbsp;Okay,&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;instead of using a separate measure for each metric, you can create a more generic solution that dynamically adapts to the selected metric.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rank_Per_Customer = 
RANKX(
    ALL(dim_customers[customer_name]), 
    [Selected_Metric_Value], 
    , DESC, Dense
)

Top_N_Customers_Metric = 
CALCULATE(
    [Selected_Metric_Value],
    FILTER(
        ALL(dim_customers[customer_name]),
        [Rank_Per_Customer] &amp;lt;= [N]
    )
)&lt;/LI-CODE&gt;&lt;P&gt;In the above code, [N] is a parameter that you need to define based on the top N customers you want to display in the line chart.&amp;nbsp;You can set this parameter in your model or use a slicer to dynamically change it.&lt;/P&gt;&lt;P&gt;Now, you can use the &lt;STRONG&gt;Top_N_Customers_Metric&lt;/STRONG&gt; measure in your line chart. Configure the line chart as follows:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;X-axis: Date from the date table.&lt;/LI&gt;&lt;LI&gt;Y-axis: Top_N_Customers_Metric.&lt;/LI&gt;&lt;LI&gt;Legend: Customer Name.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;With this setup, the line chart should dynamically adjust based on the selected metric in the slicer. You only need to create the Rank_Per_Customer and Top_N_Customers_Metric measures once, and they will work for any metric selected.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;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>Fri, 26 Jan 2024 20:19:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663398#M141969</guid>
      <dc:creator>DallasBaba</dc:creator>
      <dc:date>2024-01-26T20:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Ranking for legend.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663924#M142006</link>
      <description>&lt;P&gt;Nope, didnt work. IT gives all customers same value.&lt;BR /&gt;I tried one manual alternative, date on x axis,&amp;nbsp;Selected_Metric_Value on y axis, legend as customer name. AND on customer_name filter I did topN filter option, so I set top 5 and in "by" option i used&amp;nbsp;Selected_Metric_Value. It works.&lt;BR /&gt;&lt;BR /&gt;But I wanted to know if using measures canwe do it. Like I want to apply a Parameter slicer so that I can vary the N in top N. Now i have manually set N as 5&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jan 2024 08:50:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3663924#M142006</guid>
      <dc:creator>Swam80</dc:creator>
      <dc:date>2024-01-27T08:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Ranking for legend.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3664359#M142027</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="681124" data-lia-user-login="Swam80" class="lia-mention lia-mention-user"&gt;Swam80&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;Let's modify the measures to make it work more dynamically with a parameter slicer.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You can create a parameter table to store the value of N and then reference that parameter in your measures.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ParameterTable = DATATABLE(
    "Parameter", STRING,
    {{"TopN", "5"}}  -- Set the default value of N here
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Modify the Rank_Per_Customer measure to use the parameter:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rank_Per_Customer = 
RANKX(
    ALL(dim_customers[customer_name]), 
    [Selected_Metric_Value], 
    , DESC, Dense
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Modify the Top_N_Customers_Metric measure to reference the parameter:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top_N_Customers_Metric = 
CALCULATE(
    [Selected_Metric_Value],
    FILTER(
        ALL(dim_customers[customer_name]),
        [Rank_Per_Customer] &amp;lt;= VALUES(ParameterTable[TopN])
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Now, you can use the ParameterTable[TopN] in a slicer to dynamically change the value of N. This way, you only need to adjust the parameter to control the top N customers in your line chart.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ensure that the ParameterTable[TopN] column format is set to &lt;STRONG&gt;&lt;EM&gt;Whole Number&lt;/EM&gt;&lt;/STRONG&gt; in the Power BI model for correct filtering behavior.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope this&amp;nbsp;provides the flexibility you want, allowing you to vary the N using a parameter slicer.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jan 2024 19:53:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Ranking-for-legend/m-p/3664359#M142027</guid>
      <dc:creator>DallasBaba</dc:creator>
      <dc:date>2024-01-27T19:53:57Z</dc:date>
    </item>
  </channel>
</rss>

