<?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: Calculating filter only for certain rows in a table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5154319#M187786</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1580043" data-lia-user-login="calamistratus" class="lia-mention lia-mention-user"&gt;calamistratus&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reaching out to the Microsoft Fabric Forum Community.&lt;/P&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195973" data-lia-user-login="Juan-Power-bi" class="lia-mention lia-mention-user"&gt;Juan-Power-bi&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="251452" data-lia-user-login="AnkitKukreja" class="lia-mention lia-mention-user"&gt;AnkitKukreja&lt;/a&gt;&amp;nbsp;Thanks for the inputs.&lt;/P&gt;
&lt;P&gt;I hope the information provided by users was helpful. If you still have questions, please don't hesitate to reach out to the community.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Apr 2026 09:58:15 GMT</pubDate>
    <dc:creator>v-priyankata</dc:creator>
    <dc:date>2026-04-20T09:58:15Z</dc:date>
    <item>
      <title>Calculating filter only for certain rows in a table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5148867#M187741</link>
      <description>&lt;P&gt;I'm having troblues optimizing fitter for a table of 25K rows.&lt;/P&gt;&lt;P&gt;It contains companies and their items, there are only 100 companies and a very high number of Items.&lt;/P&gt;&lt;P&gt;The filter I want to apply picks top 5 selling companies, but the filter is memory-heavy and the PBI runs out of memory calculating it for 25k rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, can I calculate it only for the 100 companies, without repeating this for every item?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Filter calculation:&lt;/P&gt;&lt;P&gt;ShowCompany =&lt;BR /&gt;VAR N = SELECTEDVALUE('TopNValues'[Ranks])&lt;BR /&gt;&lt;BR /&gt;VAR TopNBrandN =&lt;BR /&gt;&amp;nbsp; &amp;nbsp; TOPN(N,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ALL('unique_brands'[brand]),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; [SalesForChosenPeriods],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; DESC&lt;BR /&gt;&amp;nbsp; &amp;nbsp; )&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RETURN&lt;BR /&gt;&amp;nbsp; &amp;nbsp; IF(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CONTAINS(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TopNBrandN,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; unique_brands[brand],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SELECTEDVALUE('unique_brands'[brand])&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ) || N = 0,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; )&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2026 09:57:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5148867#M187741</guid>
      <dc:creator>calamistratus</dc:creator>
      <dc:date>2026-04-15T09:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating filter only for certain rows in a table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5148969#M187745</link>
      <description>&lt;P&gt;Hola Amigo&lt;/P&gt;&lt;P&gt;The problem is that your measure runs the TOPN calculation once per row in the visual, so with 25k rows it's running 25k times. The fix is to compute it once and reuse it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The key trick is to make DAX cache the TopN result instead of recalculating it per row.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Something like this should be much lighter:&lt;BR /&gt;daxShowCompany =&lt;BR /&gt;VAR N = SELECTEDVALUE('TopNValues'[Ranks])&lt;BR /&gt;VAR TopNBrands =&lt;BR /&gt;CALCULATETABLE(&lt;BR /&gt;TOPN(N, ALL('unique_brands'[brand]), [SalesForChosenPeriods], DESC),&lt;BR /&gt;ALL('unique_brands')&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;N = 0 || SELECTEDVALUE('unique_brands'[brand]) IN TopNBrands,&lt;BR /&gt;1,&lt;BR /&gt;0&lt;BR /&gt;)&lt;BR /&gt;Using IN instead of CONTAINS is also faster. The main thing though is making sure the TOPN runs against the brand table directly without being re-evaluated in item-level context.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2026 13:05:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5148969#M187745</guid>
      <dc:creator>Juan-Power-bi</dc:creator>
      <dc:date>2026-04-15T13:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating filter only for certain rows in a table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5152190#M187770</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1580043" data-lia-user-login="calamistratus" class="lia-mention lia-mention-user"&gt;calamistratus&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;!-- ScriptorStartFragment --&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;ShowCompany :=&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;VAR N = SELECTEDVALUE ( 'TopNValues'[Ranks], 0 )&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;VAR BrandRank =&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RANKX(&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ALL ( 'unique_brands'[brand] ),&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [SalesForChosenPeriods],&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DESC,&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DENSE&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;IF ( N = 0 || BrandRank &amp;lt;= N, 1, 0 )&lt;!-- ScriptorEndFragment --&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV class=""&gt;&amp;nbsp;
&lt;DIV class=""&gt;&amp;nbsp;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 17 Apr 2026 08:44:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5152190#M187770</guid>
      <dc:creator>AnkitKukreja</dc:creator>
      <dc:date>2026-04-17T08:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating filter only for certain rows in a table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5154319#M187786</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1580043" data-lia-user-login="calamistratus" class="lia-mention lia-mention-user"&gt;calamistratus&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reaching out to the Microsoft Fabric Forum Community.&lt;/P&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195973" data-lia-user-login="Juan-Power-bi" class="lia-mention lia-mention-user"&gt;Juan-Power-bi&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="251452" data-lia-user-login="AnkitKukreja" class="lia-mention lia-mention-user"&gt;AnkitKukreja&lt;/a&gt;&amp;nbsp;Thanks for the inputs.&lt;/P&gt;
&lt;P&gt;I hope the information provided by users was helpful. If you still have questions, please don't hesitate to reach out to the community.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2026 09:58:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5154319#M187786</guid>
      <dc:creator>v-priyankata</dc:creator>
      <dc:date>2026-04-20T09:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating filter only for certain rows in a table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5156211#M187825</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1580043" data-lia-user-login="calamistratus" class="lia-mention lia-mention-user"&gt;calamistratus&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope everything’s going smoothly on your end. I wanted to check if the issue got sorted. if you have any other issues please reach community.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;SPAN data-teams="true"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2026 04:55:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-filter-only-for-certain-rows-in-a-table/m-p/5156211#M187825</guid>
      <dc:creator>v-priyankata</dc:creator>
      <dc:date>2026-04-23T04:55:55Z</dc:date>
    </item>
  </channel>
</rss>

