<?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: Average of category using only subcategories with more than x rows in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-of-category-using-only-subcategories-with-more-than-x/m-p/1804875#M38108</link>
    <description>&lt;LI-CODE lang="csharp"&gt;// If only one category has been selected,
// the measure returns the average of Value
// across all subcategories of the category
// for which the number of rows is &amp;gt;= the
// selected number from the slicer. If many
// categories are seleced, it returns the
// average of the averages as calculated above
// for each individual category.

[Category Average] =
var vMaxNumOfRowsAmongAllSubcategories =
    CALCULATE(
        MAXX(
            SUMMARIZE(
                T,
                T[Category],
                T[Subcategory]
            ),
            CALCULATE( COUNTROWS( T ) )
        )
        ALL( )
    )
var vMinNumOfRowsInSubcategories =
    SELECTEDVALUE(
        Slicer[X],
        vMaxNumOfRowsAmongAllSubcategories + 1
    )
var vCatSubcatCombinationsOfInterest =
    FILTER(
        SUMMARIZE(
            T,
            T[Category],
            T[Subcategory]
        ),
        var vRowCount = CALCULATE( COUNTROWS( T ) )
        return
            vRowCount &amp;gt;= vMinNumOfRowsInSubcategories
    )
var vResult =
    CALCULATE(
        AVERAGEX(
            DISTINCT( T[Category] ),
            CALCULATE( AVERAGE( T[Value] ) )
        ),
        vCatSubcatCombinationsOfInterest
    )
RETURN
    vResult&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 26 Apr 2021 05:08:51 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-04-26T05:08:51Z</dc:date>
    <item>
      <title>Average of category using only subcategories with more than x rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-of-category-using-only-subcategories-with-more-than-x/m-p/1803916#M38080</link>
      <description>&lt;P&gt;Hi, I want to get the average for each category, using only the subcategory rows where there are more than x rows. The number x is defined by a slicer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example, considering the following table, the calculation of each category average should ignore the red lines because those subcategories have less than 2 rows&amp;nbsp; (in case of the slicer equals to 2)&lt;/P&gt;&lt;P&gt;How can i make it?&lt;BR /&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Category&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;SubCategory&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat1&lt;/TD&gt;&lt;TD&gt;subcat1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat1&lt;/TD&gt;&lt;TD&gt;subcat1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat1&lt;/TD&gt;&lt;TD&gt;subcat1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat1&lt;/TD&gt;&lt;TD&gt;subcat2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat1&lt;/TD&gt;&lt;TD&gt;subcat2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;cat1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;subcat3&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp; 3&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat2&lt;/TD&gt;&lt;TD&gt;subcat4&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat2&lt;/TD&gt;&lt;TD&gt;subcat4&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat3&lt;/TD&gt;&lt;TD&gt;subcat1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat3&lt;/TD&gt;&lt;TD&gt;subcat1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;cat3&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;subcat2&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp; 1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;..&lt;/TD&gt;&lt;TD&gt;..&lt;/TD&gt;&lt;TD&gt;..&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;catn&lt;/TD&gt;&lt;TD&gt;subcatn&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The average should be:&lt;/P&gt;&lt;P&gt;cat1 = (1+2+3+2+3)/5,5&lt;/P&gt;&lt;P&gt;cat2 = (1+1)/2=1&lt;/P&gt;&lt;P&gt;cat2=(3+1)/2=2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 22:28:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-of-category-using-only-subcategories-with-more-than-x/m-p/1803916#M38080</guid>
      <dc:creator>SammyPub</dc:creator>
      <dc:date>2021-04-24T22:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Average of category using only subcategories with more than x rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-of-category-using-only-subcategories-with-more-than-x/m-p/1803922#M38081</link>
      <description>&lt;P&gt;Of course it's possible but without knowing your model and whether it's to be a visual average or not... it's not possible to give you a correct formula.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 23:26:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-of-category-using-only-subcategories-with-more-than-x/m-p/1803922#M38081</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-04-24T23:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Average of category using only subcategories with more than x rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-of-category-using-only-subcategories-with-more-than-x/m-p/1804126#M38086</link>
      <description>&lt;P&gt;Ok, I'm sending here the link for the pbix file: &lt;A href="https://drive.google.com/file/d/1SGdhYxWj9XVbD0_V508HjfWnjwsyymSq/view?usp=sharing" target="_self"&gt;Sample&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I reflect the changes on the slicer to table 2. It work fine for table 1.&lt;/P&gt;&lt;P&gt;On table 2, what I want is to calculate the averave using only the schools with more than x exams. The table is calculating the average for the regions with more than x exams.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 25 Apr 2021 09:49:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-of-category-using-only-subcategories-with-more-than-x/m-p/1804126#M38086</guid>
      <dc:creator>SammyPub</dc:creator>
      <dc:date>2021-04-25T09:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Average of category using only subcategories with more than x rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-of-category-using-only-subcategories-with-more-than-x/m-p/1804875#M38108</link>
      <description>&lt;LI-CODE lang="csharp"&gt;// If only one category has been selected,
// the measure returns the average of Value
// across all subcategories of the category
// for which the number of rows is &amp;gt;= the
// selected number from the slicer. If many
// categories are seleced, it returns the
// average of the averages as calculated above
// for each individual category.

[Category Average] =
var vMaxNumOfRowsAmongAllSubcategories =
    CALCULATE(
        MAXX(
            SUMMARIZE(
                T,
                T[Category],
                T[Subcategory]
            ),
            CALCULATE( COUNTROWS( T ) )
        )
        ALL( )
    )
var vMinNumOfRowsInSubcategories =
    SELECTEDVALUE(
        Slicer[X],
        vMaxNumOfRowsAmongAllSubcategories + 1
    )
var vCatSubcatCombinationsOfInterest =
    FILTER(
        SUMMARIZE(
            T,
            T[Category],
            T[Subcategory]
        ),
        var vRowCount = CALCULATE( COUNTROWS( T ) )
        return
            vRowCount &amp;gt;= vMinNumOfRowsInSubcategories
    )
var vResult =
    CALCULATE(
        AVERAGEX(
            DISTINCT( T[Category] ),
            CALCULATE( AVERAGE( T[Value] ) )
        ),
        vCatSubcatCombinationsOfInterest
    )
RETURN
    vResult&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 26 Apr 2021 05:08:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-of-category-using-only-subcategories-with-more-than-x/m-p/1804875#M38108</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-26T05:08:51Z</dc:date>
    </item>
  </channel>
</rss>

