<?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: Incorrect result - SUMX two tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-result-SUMX-two-tables/m-p/2627674#M76734</link>
    <description>&lt;P&gt;Ah! Perfect! Thanks SO much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jul 2022 12:52:32 GMT</pubDate>
    <dc:creator>Thigs</dc:creator>
    <dc:date>2022-07-08T12:52:32Z</dc:date>
    <item>
      <title>Incorrect result - SUMX two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-result-SUMX-two-tables/m-p/2626252#M76659</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with SUMX for the first time and with two different tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I have look at other similar posts, and my formula isn't throwing errors, but it isn't getting the correct result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables - Dimensions has a SKU number, height, weight, length and width. Each SKU is unique&lt;/P&gt;&lt;P&gt;Orders has Order Number, SKU number, quantity, and then several other columns not needed for this calculation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to figure out the average weight of orders per day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my formula -&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;New Measure Try = &lt;/SPAN&gt;&lt;SPAN&gt;sumx&lt;/SPAN&gt;&lt;SPAN&gt;(Orders,&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Orders[Quantity]&lt;/SPAN&gt;&lt;SPAN&gt; * &lt;/SPAN&gt;&lt;SPAN&gt;AVERAGE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Dimensions'[weight]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This is getting larger numbers than when I do it in Excel. Is the "Average" the issue? I can't seem to tell it to do SUMX without using some kind of calculation for the second table. The two tables have a one-many relationship, with Dimensions being the one.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Any help is super appreciated!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 07 Jul 2022 21:19:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-result-SUMX-two-tables/m-p/2626252#M76659</guid>
      <dc:creator>Thigs</dc:creator>
      <dc:date>2022-07-07T21:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect result - SUMX two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-result-SUMX-two-tables/m-p/2626283#M76661</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="337817" data-lia-user-login="Thigs" class="lia-mention lia-mention-user"&gt;Thigs&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on what you've described, here is what I would suggest if I were creating these calculations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create these measures:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Order Quantity =
SUM ( Orders[Quantity] )&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Total Weight =
SUMX (
    SUMMARIZE ( Orders, 'Dimensions'[weight] ),
    'Dimensions'[weight] * [Order Quantity]
)&lt;/LI-CODE&gt;
&lt;P&gt;The Total Weight measure takes the distinct weights for SKUs appearing in the Orders table, and multiplies these by the corresponding Order Quantity and sums.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then for the average weight, did you want the average weight per order?&lt;/P&gt;
&lt;P&gt;You would first need a measure that returns the Order Count, either by counting distinct Order Numbers, or counting rows of Orders (whichever is correct), i.e.:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Order Count =
DISTINCTCOUNT ( Orders[Order Number] )&lt;/LI-CODE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Order Count =
COUNTROWS ( Orders )&lt;/LI-CODE&gt;
&lt;P&gt;Then the average weight per order would be:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Order Average Weight =
DIVIDE ( [Total Weight], [Order Count] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the above help get the result you were looking for?&lt;/P&gt;
&lt;P&gt;Please post back if needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 22:03:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-result-SUMX-two-tables/m-p/2626283#M76661</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2022-07-07T22:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect result - SUMX two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-result-SUMX-two-tables/m-p/2627674#M76734</link>
      <description>&lt;P&gt;Ah! Perfect! Thanks SO much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 12:52:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-result-SUMX-two-tables/m-p/2627674#M76734</guid>
      <dc:creator>Thigs</dc:creator>
      <dc:date>2022-07-08T12:52:32Z</dc:date>
    </item>
  </channel>
</rss>

