<?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 Totals even with SUMX! in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4394403#M174457</link>
    <description>&lt;P&gt;You are my hero!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! thank you so much!!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2025 12:47:29 GMT</pubDate>
    <dc:creator>yzornetta</dc:creator>
    <dc:date>2025-02-04T12:47:29Z</dc:date>
    <item>
      <title>Incorrect Totals even with SUMX!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390207#M174284</link>
      <description>&lt;P&gt;Hi All!&lt;/P&gt;&lt;P&gt;Like many others, I'm experiencing issues with Totals in a Matrix. Despite trying various solutions involving SUMX and SUMMARIZE, I couldn’t solve it so far.&lt;/P&gt;&lt;P&gt;I've &lt;A href="https://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Fdrive%2Ffolders%2F1-AeLucCIVz69TiGZdLfwjAml1p75Fk20%3Fusp%3Dsharing_eip%26invite%3DCJnAma4J%26ts%3D679cede3&amp;amp;data=05%7C02%7Czornettay%40oscogroup.com%7Ccfbd7e82138c43a18a6008dd420cf905%7C0ee60ac450594f1c857ca9c4d2daab23%7C0%7C0%7C638739345665457315%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&amp;amp;sdata=cebqkNj2mTkJ8kNL%2Flzfib7wPeG%2BD%2BEbTxE1PmCMU20%3D&amp;amp;reserved=0" target="_blank" rel="noopener"&gt;attached a file&lt;/A&gt; with sample data for your reference.&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;To calculate Total Revenue, I need to multiply a fixed rate (specific to each Branch and Fiscal Year) by the total units sold. The rate value is stored in a static table (F0902) that is not directly related to my data model. Therefore, I use the TREATAS function to establish the necessary relationships.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Total Revenue = &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;VAR rate_x_meter =&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; CALCULATE(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; SUM(F0902'[Rate per meter]),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; TREATAS(VALUES(F1201'[ResponsibleBU]), F0902'[BusinessUnit]),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; TREATAS(VALUES(F1202-F0911'[FiscalYear]), F0902'[FiscalYear])&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;rate_x_meter * [Units Sold]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My units are calculated in a separate measure, which aggregates all units sold based on a specified Period parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Units Sold = &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CALCULATE(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SWITCH( 'Period'[Period Value],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1, SUM(F1202-F0911'[Period01Balance]),&lt;/P&gt;&lt;P&gt;2, SUM(F1202-F0911'[Period01Balance]) + SUM(F1202-F0911'[Period02Balance]),&lt;/P&gt;&lt;P&gt;3, SUM(F1202-F0911'[Period01Balance]) + SUM(F1202-F0911'[Period02Balance]) + SUM(F1202-F0911'[Period03Balance]),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FILTER(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;F1202-F0911',&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (RELATED('ObjectAccount'[AccountNumber])= "31600"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data model:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All subtotals by branch are ok, but the problem is the final total as you see in my first screenshot.&lt;/P&gt;&lt;P&gt;Could you please help me? I’ve been trying a lot, and it is driving me crazy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 15:40:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390207#M174284</guid>
      <dc:creator>yzornetta</dc:creator>
      <dc:date>2025-01-31T15:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Totals even with SUMX!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390243#M174285</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="922512" data-lia-user-login="yzornetta" class="lia-mention lia-mention-user"&gt;yzornetta&lt;/a&gt;&amp;nbsp;- The SUMX for the total is calculating at the Aggregate level, it will not iterate throught the rows of your table unless you tell it to. I suggest you use a pattern like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VAR _table =
    ADDCOLUMNS (
        SUMMARIZE ( 'Branch', 'Branch'[Column 1], 'Branch'[Column 2] ),
        "units", [Units Sold],
        "rate_x_meter",
            CALCULATE (
                SUM ( 'F0902'[Rate per meter] ),
                TREATAS ( VALUES ( 'F1201'[ResponsibleBU] ), 'F0902'[BusinessUnit] ),
                TREATAS ( VALUES ( 'F1202-F0911'[FiscalYear] ), 'F0902'[FiscalYear] )
            )
    )
RETURN
    SUMX ( _table, [rate_x_meter] * [units] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this works, please accept it as the solution to help others with the same challenge.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 16:07:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390243#M174285</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2025-01-31T16:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Totals even with SUMX!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390269#M174286</link>
      <description>&lt;P&gt;Hello! thanks for your time, unfortunately I tried it but it is still the same:&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;</description>
      <pubDate>Fri, 31 Jan 2025 16:23:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390269#M174286</guid>
      <dc:creator>yzornetta</dc:creator>
      <dc:date>2025-01-31T16:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Totals even with SUMX!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390295#M174289</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="922512" data-lia-user-login="yzornetta" class="lia-mention lia-mention-user"&gt;yzornetta&lt;/a&gt;&amp;nbsp;You have two columns in your matrix, but only one in the SUMMARIZE, please try adding the additional column.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 16:34:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390295#M174289</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2025-01-31T16:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Totals even with SUMX!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390375#M174294</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="343036" data-lia-user-login="mark_endicott" class="lia-mention lia-mention-user"&gt;mark_endicott&lt;/a&gt;&amp;nbsp;I can not added it in the SUMMARIZE as this column is not from the Branch table, what can I do in this case?&amp;nbsp;&amp;nbsp;&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;</description>
      <pubDate>Fri, 31 Jan 2025 17:42:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390375#M174294</guid>
      <dc:creator>yzornetta</dc:creator>
      <dc:date>2025-01-31T17:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Totals even with SUMX!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390395#M174296</link>
      <description>&lt;P&gt;I updated the formula to include both columns in the SUMMARIZE, but it is still not working &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 18:11:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390395#M174296</guid>
      <dc:creator>yzornetta</dc:creator>
      <dc:date>2025-01-31T18:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Totals even with SUMX!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390426#M174297</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="922512" data-lia-user-login="yzornetta" class="lia-mention lia-mention-user"&gt;yzornetta&lt;/a&gt;&amp;nbsp;First, please vote for this idea: &lt;A href="https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e" target="_blank"&gt;https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This looks like a measure totals problem. Very common. See my post about it here: &lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376" target="_blank"&gt;https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also: &lt;A href="https://youtu.be/uXRriTN0cfY" target="_blank"&gt;https://youtu.be/uXRriTN0cfY&lt;/A&gt;&lt;BR /&gt;And: &lt;A href="https://youtu.be/n4TYhF2ARe8" target="_blank"&gt;https://youtu.be/n4TYhF2ARe8&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 18:40:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4390426#M174297</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2025-01-31T18:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Totals even with SUMX!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4393375#M174408</link>
      <description>&lt;P&gt;Thanks for the reply from Greg_Deckler&amp;nbsp; and mark_endicott&amp;nbsp;, please allow me to add some more information:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Hi&amp;nbsp; &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="922512" data-lia-user-login="yzornetta" class="lia-mention lia-mention-user"&gt;yzornetta&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Measure follows the context of the "Total" row and is calculated in that context. Therefore, using a measure in a column of a table visualization may have unexpected values in the "Total" column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the IF()+HASONEVALUE() function to determine whether it is “Row subtotals” or “Row grand total”, and if it is, you can add as many columns as you want. If it is, you can add the columns that appear in the visual to do the calculation, such as the average, Sum and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try the following dax and replace the table and column names that appear below with the corresponding column names that appear in visual.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
IF(
    HASONEVALUE('Table'[Description]),SUMX('Table',[Total Revenue]),
IF(
    HASONEVALUE('Table'[Branch]),SUMX(FILTER(ALL('Table'),[Branch]=MAX([Branch])),[Total Revenue]),
    SUMX(
      ALL('Table'),[Total Revenue]))
    )&lt;/LI-CODE&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;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 03:20:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4393375#M174408</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-04T03:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Totals even with SUMX!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4394070#M174449</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="922512" data-lia-user-login="yzornetta" class="lia-mention lia-mention-user"&gt;yzornetta&lt;/a&gt;&amp;nbsp;- Sorry for the delay.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The suggestions made here would all work, except for the fact that your Rate per meter calculation does not work at the 3 levels (Branch Description, Unit Description, Total) when calculated inside the Total Revenue measure, hence why this does not all correctly aggregate at the total level. It therefore needs to be calculated in a separate measure, and then referenced in this measure.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This means the Total Revenue measure (according to your sample data) you need to use is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VAR _table =
    SUMMARIZECOLUMNS (
        'PRODCTL F0005 (Branch)'[Description],
        'PRODDTA F1201'[Unit - Description]
    )
RETURN
    IF (
        HASONEVALUE ( 'PRODCTL F0005 (Branch)'[Description] ),
        SUMX ( _table, - ( [Rate per meter] * [Units Sold] ) ),
        SUMX (
            ALL ( 'PRODCTL F0005 (Branch)'[Description] ),
            - ( [Rate per meter] * [Units Sold] )
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See below for expected total:&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;Please accept this as the solution so others with the same challenge can find the answer.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 16:45:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4394070#M174449</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2025-02-04T16:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Totals even with SUMX!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4394403#M174457</link>
      <description>&lt;P&gt;You are my hero!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! thank you so much!!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 12:47:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Incorrect-Totals-even-with-SUMX/m-p/4394403#M174457</guid>
      <dc:creator>yzornetta</dc:creator>
      <dc:date>2025-02-04T12:47:29Z</dc:date>
    </item>
  </channel>
</rss>

