<?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: Count rows for top n categories in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-for-top-n-categories/m-p/1418367#M26348</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="64216" data-lia-user-login="soldous" class="lia-mention lia-mention-user"&gt;soldous&lt;/a&gt;&amp;nbsp;, a table itself can be used as filter in CALCULATE. You may want to try a measure in this pattern,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure =
VAR __topn =
    TOPN (
        5,
        VALUES ( Table[Category Level 1] ),
        RANKX ( ALL ( Table[Category Level 1] ), COUNTROWS ( Table ),, ASC )
    )
RETURN
    CALCULATE ( COUNTROWS ( Table ), __topn )&lt;/LI-CODE&gt;&lt;P&gt;It's a general idea; you're supposed to base the measure on specific context of your data model.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Oct 2020 13:36:59 GMT</pubDate>
    <dc:creator>CNENFRNL</dc:creator>
    <dc:date>2020-10-07T13:36:59Z</dc:date>
    <item>
      <title>Count rows for top n categories</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-for-top-n-categories/m-p/1418321#M26346</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to count rows in the table which is filtered only for top n most frequent categories.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know how to get these categories:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TOPN (
        5, 
        VALUES ( Table[Category Level 1] ), 
        RANKX( ALL( Table[Category Level 1] ),COUNTROWS(Table),,ASC)
    )&lt;/LI-CODE&gt;&lt;P&gt;But I don't know how to use this as i filter for CALCULATE(COUNTROWS(Table),..)&lt;/P&gt;&lt;P&gt;I was thinking about using IN operator and something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE(COUNTROWS(Table),FILTER(Table,Table[Category Level 1] IN CALCULATETABLE(TOPN (
        5, 
        VALUES ( Table[Category Level 1] ), 
        RANKX( ALL( Table[Category Level 1] ),COUNTROWS(Table),,ASC)
    ))))&lt;/LI-CODE&gt;&lt;P&gt;but it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone help?&lt;/P&gt;&lt;P&gt;The solution without FILTER would be much appreciated because the table is quite huge and the FILTER function is incredibly slow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 13:17:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-for-top-n-categories/m-p/1418321#M26346</guid>
      <dc:creator>soldous</dc:creator>
      <dc:date>2020-10-07T13:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Count rows for top n categories</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-for-top-n-categories/m-p/1418367#M26348</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="64216" data-lia-user-login="soldous" class="lia-mention lia-mention-user"&gt;soldous&lt;/a&gt;&amp;nbsp;, a table itself can be used as filter in CALCULATE. You may want to try a measure in this pattern,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure =
VAR __topn =
    TOPN (
        5,
        VALUES ( Table[Category Level 1] ),
        RANKX ( ALL ( Table[Category Level 1] ), COUNTROWS ( Table ),, ASC )
    )
RETURN
    CALCULATE ( COUNTROWS ( Table ), __topn )&lt;/LI-CODE&gt;&lt;P&gt;It's a general idea; you're supposed to base the measure on specific context of your data model.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 13:36:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-for-top-n-categories/m-p/1418367#M26348</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2020-10-07T13:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Count rows for top n categories</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-for-top-n-categories/m-p/1418399#M26349</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="250150" data-lia-user-login="CNENFRNL" class="lia-mention lia-mention-user"&gt;CNENFRNL&lt;/a&gt;&amp;nbsp;Thank you very much!&lt;/P&gt;&lt;P&gt;There is always something new to learn &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 13:43:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-for-top-n-categories/m-p/1418399#M26349</guid>
      <dc:creator>soldous</dc:creator>
      <dc:date>2020-10-07T13:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Count rows for top n categories</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-for-top-n-categories/m-p/2847695#M91167</link>
      <description>&lt;P&gt;Is there a way to connect this to a slicer?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 22:46:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-for-top-n-categories/m-p/2847695#M91167</guid>
      <dc:creator>TSki</dc:creator>
      <dc:date>2022-10-17T22:46:23Z</dc:date>
    </item>
  </channel>
</rss>

