<?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 Top N calculation for time series visual in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Top-N-calculation-for-time-series-visual/m-p/4330575#M171904</link>
    <description>&lt;P&gt;I think you need to tweak the Top_Cities variable to use ALLSELECTED('Date')&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Top Orders | Cities =
VAR N = 'Top N'[Top N Value] -- Get the top N cities by total orders
VAR Top_Cities =
    CALCULATETABLE (
        TOPN ( N, ALLSELECTED ( 'Cities'[City] ), [Total Orders] ),
        ALLSELECTED ( 'Date' )
    ) -- Calculate the total orders for the Top N cities
VAR TopN_Orders =
    CALCULATE ( [Total Orders], KEEPFILTERS ( Top_Cities ) ) -- Calculate total orders for all selected cities
VAR All_Orders =
    CALCULATE ( [Total Orders], ALLSELECTED ( Cities ) ) -- Calculate the total orders for cities that are not in the Top N
VAR Other_Orders =
    All_Orders - CALCULATE ( [Total Orders], Top_Cities )
VAR Result =
    SWITCH (
        TRUE (),
        NOT ISINSCOPE ( Cities[City] ), All_Orders,
        SELECTEDVALUE ( Cities[City] ) = "Others", Other_Orders,
        TopN_Orders
    )
RETURN
    Result
&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 16 Dec 2024 09:55:38 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2024-12-16T09:55:38Z</dc:date>
    <item>
      <title>Dynamic Top N calculation for time series visual</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Top-N-calculation-for-time-series-visual/m-p/4330223#M171890</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a dynamic Top N calculation which follows the DAX logic in an article &lt;A href="https://www.linkedin.com/pulse/power-bi-dynamic-top-n-include-others-using-parameter-ali--6f2af" target="_self"&gt;linked here.&amp;nbsp;&lt;/A&gt;I have also pasted this DAX at the bottom this message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whilst this measure works as intended, when used in a time series line graph it evaluates the top N selection at each data point. Instead, I want it to evaluate across the entire data range in the visualisation - &lt;STRONG&gt;the same way the Top N filter works&lt;/STRONG&gt; when applied to a graph.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see example below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would be extremely grateful for assistance on this one -- have sunk considerable time in without any result!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DAX from linked article above:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;Top Orders | Cities = 

VAR N = 'Top N'[Top N Value]

-- Get the top N cities by total orders
VAR Top_Cities = 
    TOPN( 
        N, 
        ALLSELECTED('Cities'[City]), 
        [Total Orders] 
    )

-- Calculate the total orders for the Top N cities
VAR TopN_Orders = 
    CALCULATE(
        [Total Orders],
        KEEPFILTERS(Top_Cities)
    )

-- Calculate total orders for all selected cities
VAR All_Orders = 
    CALCULATE(
        [Total Orders],
        ALLSELECTED(Cities)
    )

-- Calculate the total orders for cities that are not in the Top N
VAR Other_Orders = 
    All_Orders - CALCULATE([Total Orders], Top_Cities)


VAR Result = 
    SWITCH(
        TRUE(),
        NOT ISINSCOPE(Cities[City]), All_Orders,
        SELECTEDVALUE(Cities[City]) = "Others", Other_Orders,
        TopN_Orders
    )



RETURN 
    Result&lt;/SPAN&gt;&lt;/PRE&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>Mon, 16 Dec 2024 06:28:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Top-N-calculation-for-time-series-visual/m-p/4330223#M171890</guid>
      <dc:creator>PBI12345</dc:creator>
      <dc:date>2024-12-16T06:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Top N calculation for time series visual</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Top-N-calculation-for-time-series-visual/m-p/4330575#M171904</link>
      <description>&lt;P&gt;I think you need to tweak the Top_Cities variable to use ALLSELECTED('Date')&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Top Orders | Cities =
VAR N = 'Top N'[Top N Value] -- Get the top N cities by total orders
VAR Top_Cities =
    CALCULATETABLE (
        TOPN ( N, ALLSELECTED ( 'Cities'[City] ), [Total Orders] ),
        ALLSELECTED ( 'Date' )
    ) -- Calculate the total orders for the Top N cities
VAR TopN_Orders =
    CALCULATE ( [Total Orders], KEEPFILTERS ( Top_Cities ) ) -- Calculate total orders for all selected cities
VAR All_Orders =
    CALCULATE ( [Total Orders], ALLSELECTED ( Cities ) ) -- Calculate the total orders for cities that are not in the Top N
VAR Other_Orders =
    All_Orders - CALCULATE ( [Total Orders], Top_Cities )
VAR Result =
    SWITCH (
        TRUE (),
        NOT ISINSCOPE ( Cities[City] ), All_Orders,
        SELECTEDVALUE ( Cities[City] ) = "Others", Other_Orders,
        TopN_Orders
    )
RETURN
    Result
&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 16 Dec 2024 09:55:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Top-N-calculation-for-time-series-visual/m-p/4330575#M171904</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2024-12-16T09:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Top N calculation for time series visual</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Top-N-calculation-for-time-series-visual/m-p/4330626#M171906</link>
      <description>&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked exactly as hoped. Thank you so much.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 10:33:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Top-N-calculation-for-time-series-visual/m-p/4330626#M171906</guid>
      <dc:creator>PBI12345</dc:creator>
      <dc:date>2024-12-16T10:33:26Z</dc:date>
    </item>
  </channel>
</rss>

