<?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: Group by one column and get average from another column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-by-one-column-and-get-average-from-another-column/m-p/4012210#M157994</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sure, the SUMMARIZE() function can instead of the GROUPBY():&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MEASURE 2 =
VAR _vtable =
    SUMMARIZE (
        ALLSELECTED ( 'Table' ),
        'Table'[Char],
        "_AVG", AVERAGE ( 'Table'[Value] )
    )
RETURN
    MAXX ( FILTER ( _vtable, [Char] = SELECTEDVALUE ( 'Table'[Char] ) ), [_AVG] )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;As my testing,&amp;nbsp;measure2 runs faster than measure and seems to use less memory.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;About ALLSELECTED() function, it's not necessary in table, in measure, the ALLSELECTED() function is often used.&lt;/P&gt;
&lt;P&gt;This link can be help:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/Understand-the-Filter-Context-and-How-to-Control-it/ba-p/2452011#:~:text=1.-,Relationship%20filter,-Add%20a%20table" target="_blank"&gt;Understand the Filter Context and How to Control i... - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The _AVGTable returns a table:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;[Char] = SELECTEDVALUE ( 'Table'[Char] ) //The [Char] is the [Char] column in _AVGTable, the SELECTEDVALUE ( 'Table'[Char] ) returns the [Char] in Original Table, this function is to get the right outcome from the virtual table _AVGTable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Zhengdong Xu&lt;BR /&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jun 2024 01:24:51 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-06-27T01:24:51Z</dc:date>
    <item>
      <title>Group by one column and get average from another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-by-one-column-and-get-average-from-another-column/m-p/4007689#M157018</link>
      <description>&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;I have following table&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;and I want to get with DAX avg for each character, so result should be this&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;unfornatelly GROUP BY is not working as I expect..can anyone help me to understand where I am wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;and what should be correct formula ?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 20:13:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-by-one-column-and-get-average-from-another-column/m-p/4007689#M157018</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-24T20:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Group by one column and get average from another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-by-one-column-and-get-average-from-another-column/m-p/4007917#M157159</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The GROUPBY() function returns a table, so you can get the right outcome in calculated table:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Or you can change the measure into this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MEASURE =
VAR _AVGTable =
    GROUPBY (
        ALLSELECTED ( 'Table' ),
        'Table'[Char],
        "_AVG", AVERAGEX ( CURRENTGROUP (), 'Table'[Value] )
    )
RETURN
    MAXX ( FILTER ( _AVGTable, [Char] = SELECTEDVALUE ( 'Table'[Char] ) ), [_AVG] )
&lt;/LI-CODE&gt;
&lt;P&gt;The result is as follow:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Zhengdong Xu&lt;BR /&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 01:20:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-by-one-column-and-get-average-from-another-column/m-p/4007917#M157159</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-25T01:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Group by one column and get average from another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-by-one-column-and-get-average-from-another-column/m-p/4011911#M157959</link>
      <description>&lt;P&gt;thanks, and 3 more mini questions &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; before I click on Accept as a solution&lt;BR /&gt;1) can I use summarize instead of group by ? is better?&lt;/P&gt;&lt;P&gt;2) why are used functions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -ALLSELECTED in table ? is it neccessary ?&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -MAXX (when FILTER is iterator of the filtered table)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp; [Char] = SELECTEDVALUE ( 'Table'[Char] ) ? Sorry I dont get it, because this condition will be always true&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sorry to bother you, but I want to understand the logic of it &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 18:59:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-by-one-column-and-get-average-from-another-column/m-p/4011911#M157959</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-26T18:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Group by one column and get average from another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-by-one-column-and-get-average-from-another-column/m-p/4012210#M157994</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sure, the SUMMARIZE() function can instead of the GROUPBY():&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MEASURE 2 =
VAR _vtable =
    SUMMARIZE (
        ALLSELECTED ( 'Table' ),
        'Table'[Char],
        "_AVG", AVERAGE ( 'Table'[Value] )
    )
RETURN
    MAXX ( FILTER ( _vtable, [Char] = SELECTEDVALUE ( 'Table'[Char] ) ), [_AVG] )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;As my testing,&amp;nbsp;measure2 runs faster than measure and seems to use less memory.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;About ALLSELECTED() function, it's not necessary in table, in measure, the ALLSELECTED() function is often used.&lt;/P&gt;
&lt;P&gt;This link can be help:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/Understand-the-Filter-Context-and-How-to-Control-it/ba-p/2452011#:~:text=1.-,Relationship%20filter,-Add%20a%20table" target="_blank"&gt;Understand the Filter Context and How to Control i... - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The _AVGTable returns a table:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;[Char] = SELECTEDVALUE ( 'Table'[Char] ) //The [Char] is the [Char] column in _AVGTable, the SELECTEDVALUE ( 'Table'[Char] ) returns the [Char] in Original Table, this function is to get the right outcome from the virtual table _AVGTable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Zhengdong Xu&lt;BR /&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 01:24:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-by-one-column-and-get-average-from-another-column/m-p/4012210#M157994</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-27T01:24:51Z</dc:date>
    </item>
  </channel>
</rss>

