<?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: Using SUMX twice within GROUPBY expression in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2225924#M52994</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;Did you have a chance to look into this?&lt;/P&gt;</description>
    <pubDate>Tue, 07 Dec 2021 16:11:12 GMT</pubDate>
    <dc:creator>smpa01</dc:creator>
    <dc:date>2021-12-07T16:11:12Z</dc:date>
    <item>
      <title>Using SUMX twice within GROUPBY expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2218953#M52610</link>
      <description>&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Unit&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Category&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Score&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Weight&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Unit A&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Unit A&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Unit A&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Unit B&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Unit B&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Unit C&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;W&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, what I want to do is, within each unit, add up the product of the scores and their corresponding weights, and divide by the sum of the weights within each unit. These should be displayed in a table. The output table should look like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Unit&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Calculated Column&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Unit A&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Unit B&lt;/TD&gt;&lt;TD&gt;1.5625&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Unit C&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been fighting with this for hours and am pretty frustrated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Calculation =&amp;nbsp;&lt;SPAN&gt;GROUPBY(&lt;/SPAN&gt;&lt;SPAN&gt;'Proper Business Unit Rollup Step 2 Table'[Unit],&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"Calculated Column",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUMX(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CURRENTGROUP(),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;'Table'[Score]*'Table'[Weight])/SUMX(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CURRENTGROUP(), Table[Score]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;When I do this I get the following error:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;No table scans other than introduced by GroupBy() function are allowed before CurrentGroup() functions.&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It doesn't seem to like me putting two SUMX(CURRENTGROUP(),...) in the GROUPBY expression. How can I make this work?&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 02 Dec 2021 23:29:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2218953#M52610</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-12-02T23:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUMX twice within GROUPBY expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2218974#M52613</link>
      <description>&lt;P&gt;NewTable=ADDCOLUMNS(VALUES('Table'[Unit]),"@CalCol",CALCULATE(DIVIDE(SUMX('Table','Table'[Score]*'Table'[Weight]),SUM('Table'[Weight]))))&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 00:26:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2218974#M52613</guid>
      <dc:creator>wdx223_Daniel</dc:creator>
      <dc:date>2021-12-03T00:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUMX twice within GROUPBY expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2219273#M52618</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp; try this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Measure =&lt;BR /&gt;VAR _sum =&lt;BR /&gt;SUMX ( tbl, tbl[score] * tbl[weight] )&lt;BR /&gt;VAR _count =&lt;BR /&gt;CALCULATE ( SUM ( tbl[weight] ), ALLEXCEPT ( tbl, tbl[unit] ) )&lt;BR /&gt;RETURN&lt;BR /&gt;DIVIDE ( _sum, _count )&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 04:31:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2219273#M52618</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2021-12-03T04:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUMX twice within GROUPBY expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2219278#M52619</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;if you want to use groupby function, please try the below. (attached file).&lt;/P&gt;
&lt;P&gt;It is for creating a new table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;New table =&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;EM&gt;VAR newtable =&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;GROUPBY (&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Data,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Data[Unit],&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"@scoreweight", SUMX ( CURRENTGROUP (), Data[Score] * Data[Weight] ),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"@weightsum", SUMX ( CURRENTGROUP (), Data[Weight] )&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;RETURN&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;GROUPBY (&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;newtable,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Data[Unit],&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"@calculatedColumn", SUMX ( CURRENTGROUP (), [@scoreweight] / [@weightsum] )&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 04:37:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2219278#M52619</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2021-12-03T04:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUMX twice within GROUPBY expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2224689#M52925</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;You may try this Calculated Column.&lt;/P&gt;
&lt;P&gt;Calculated Column =&lt;/P&gt;
&lt;P&gt;DIVIDE (&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Table'[Score] * 'Table'[Weight],&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALCULATE ( SUM ( 'Table'[Weight] ), ALLEXCEPT ( 'Table', 'Table'[Unit] ) )&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result should look like this:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more details, please refer to the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _ Caiyun&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly. If you still have problems on it or I misunderstand your needs, please feel free to let us know. Thanks a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 07:39:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2224689#M52925</guid>
      <dc:creator>v-cazheng-msft</dc:creator>
      <dc:date>2021-12-07T07:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUMX twice within GROUPBY expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2225924#M52994</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;Did you have a chance to look into this?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 16:11:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-SUMX-twice-within-GROUPBY-expression/m-p/2225924#M52994</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2021-12-07T16:11:12Z</dc:date>
    </item>
  </channel>
</rss>

