<?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: Matrix Table Row subtotal different with each row in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3469952#M132485</link>
    <description>&lt;P&gt;Hi Sir,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much replied my question. Apperciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ac =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;VAR c = { "a", "b", "c" }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DISTINCTCOUNT ( sales[cust_cd] ),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FILTER (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ALL ( sales ),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RELATED ( cust[a] ) IN c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; RELATED ( cust[s] ) IN { 'T' }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; [Net Amt] &amp;gt; 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Result become:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Year Month | ac&lt;/P&gt;&lt;P&gt;2023-08&amp;nbsp; &amp;nbsp; &amp;nbsp; | &lt;STRONG&gt;9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2023-09&amp;nbsp; &amp;nbsp; &amp;nbsp; | &lt;STRONG&gt;9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2023-10&amp;nbsp; &amp;nbsp; &amp;nbsp; | &lt;STRONG&gt;9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Total&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ac =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;VAR c = {"a", "b", "c"}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CALCULATE(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DISTINCTCOUNT(sales[cust_cd]),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FILTER( sales,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RELATED(cust[a]) IN c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; RELATED(cust[s]) IN {"T"}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; [Net Amt] &amp;gt; 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ALL(sales) // This removes filter context on 'sales' for the total row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Result:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Year Month | ac&lt;/P&gt;&lt;P&gt;2023-08&amp;nbsp; &amp;nbsp; &amp;nbsp; | 8186&lt;/P&gt;&lt;P&gt;2023-09&amp;nbsp; &amp;nbsp; &amp;nbsp; | 8125&lt;/P&gt;&lt;P&gt;2023-10&amp;nbsp; &amp;nbsp; &amp;nbsp; | 2815&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Total&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still not get the result as per expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2023 23:31:53 GMT</pubDate>
    <dc:creator>ChaCha123</dc:creator>
    <dc:date>2023-10-10T23:31:53Z</dc:date>
    <item>
      <title>Matrix Table Row subtotal different with each row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3468725#M132419</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I creating a DAX formula with the multiple filter condition, this is total number for each row is correct but the Matrix Table Row Total different when calculate each row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my DAX formula&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ac = VAR c = {"a","b","c"}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RETURN&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CALCULATE(DISTINCTCOUNT(sales[cust_cd]), FILTER(sales, RELATED(cust[a]) in c&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;&amp;amp; RELATED(cust[s]) in {'T'}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;&amp;amp; [Net Amt] &amp;gt;0))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Matrix Table&lt;/P&gt;&lt;P&gt;Year Month | ac&lt;/P&gt;&lt;P&gt;2023-08&amp;nbsp; &amp;nbsp; &amp;nbsp; | 8186&lt;/P&gt;&lt;P&gt;2023-09&amp;nbsp; &amp;nbsp; &amp;nbsp; | 8125&lt;/P&gt;&lt;P&gt;2023-10&amp;nbsp; &amp;nbsp; &amp;nbsp; | 2815&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Total&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By right, the result return&lt;/P&gt;&lt;P&gt;Year Month | ac&lt;/P&gt;&lt;P&gt;2023-08&amp;nbsp; &amp;nbsp; &amp;nbsp; | 8186&lt;/P&gt;&lt;P&gt;2023-09&amp;nbsp; &amp;nbsp; &amp;nbsp; | 8125&lt;/P&gt;&lt;P&gt;2023-10&amp;nbsp; &amp;nbsp; &amp;nbsp; | 2815&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Total&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 19126&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope someone can help me. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 11:56:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3468725#M132419</guid>
      <dc:creator>ChaCha123</dc:creator>
      <dc:date>2023-10-10T11:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix Table Row subtotal different with each row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3469529#M132453</link>
      <description>&lt;P&gt;DISTINCTCOUNT is not an additive measure by nature. Rarely, it will be additive if there is no overlap between rows.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recommend you to read these articles:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/obtaining-accurate-totals-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/obtaining-accurate-totals-in-dax/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/td-p/547907" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/td-p/547907&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typically, if you want to force to get distinct count in total rows also is like this ... Try and adjust the formula to your needs. Hope it helps!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;ac = 

VAR c = {"a","b","c"}
var _calc = CALCULATE(DISTINCTCOUNT(sales[cust_cd]), FILTER(sales, RELATED(cust[a]) in c
               &amp;amp;&amp;amp; RELATED(cust[s]) in {'T'}    &amp;amp;&amp;amp; [Net Amt] &amp;gt;0))

--Basically, you are looping through all the values of your category, do the calculation for each value (row) and add
 
var _calc2 = Sumx( values(Table1[Year Month Category]), CALCULATE(DISTINCTCOUNT(sales[cust_cd]), FILTER(sales, RELATED(cust[a]) in c
               &amp;amp;&amp;amp; RELATED(cust[s]) in {'T'}    &amp;amp;&amp;amp; [Net Amt] &amp;gt;0)))

RETURN IF ( HasOneValue( Table1[Year Month Category]), _calc, _calc2)
           

&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 10 Oct 2023 18:19:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3469529#M132453</guid>
      <dc:creator>sevenhills</dc:creator>
      <dc:date>2023-10-10T18:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix Table Row subtotal different with each row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3469539#M132456</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="629003" data-lia-user-login="ChaCha123" class="lia-mention lia-mention-user"&gt;ChaCha123&lt;/a&gt;&amp;nbsp;&amp;nbsp;You can try using the ALL function using the following expressions:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ac =&lt;BR /&gt;VAR c = { "a", "b", "c" }&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE (&lt;BR /&gt;DISTINCTCOUNT ( sales[cust_cd] ),&lt;BR /&gt;FILTER (&lt;BR /&gt;ALL ( sales ),&lt;BR /&gt;RELATED ( cust[a] ) IN c&lt;BR /&gt;&amp;amp;&amp;amp; RELATED ( cust[s] ) IN { 'T' }&lt;BR /&gt;&amp;amp;&amp;amp; [Net Amt] &amp;gt; 0&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;========== OR ======&lt;/P&gt;&lt;P&gt;ac =&lt;BR /&gt;VAR c = {"a", "b", "c"}&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;DISTINCTCOUNT(sales[cust_cd]),&lt;BR /&gt;FILTER( sales,&lt;BR /&gt;RELATED(cust[a]) IN c&lt;BR /&gt;&amp;amp;&amp;amp; RELATED(cust[s]) IN {"T"}&lt;BR /&gt;&amp;amp;&amp;amp; [Net Amt] &amp;gt; 0&lt;BR /&gt;),&lt;BR /&gt;ALL(sales) // This removes filter context on 'sales' for the total row&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Please let me know if this helped.&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 18:27:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3469539#M132456</guid>
      <dc:creator>DallasBaba</dc:creator>
      <dc:date>2023-10-10T18:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix Table Row subtotal different with each row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3469952#M132485</link>
      <description>&lt;P&gt;Hi Sir,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much replied my question. Apperciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ac =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;VAR c = { "a", "b", "c" }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DISTINCTCOUNT ( sales[cust_cd] ),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FILTER (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ALL ( sales ),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RELATED ( cust[a] ) IN c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; RELATED ( cust[s] ) IN { 'T' }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; [Net Amt] &amp;gt; 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Result become:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Year Month | ac&lt;/P&gt;&lt;P&gt;2023-08&amp;nbsp; &amp;nbsp; &amp;nbsp; | &lt;STRONG&gt;9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2023-09&amp;nbsp; &amp;nbsp; &amp;nbsp; | &lt;STRONG&gt;9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2023-10&amp;nbsp; &amp;nbsp; &amp;nbsp; | &lt;STRONG&gt;9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Total&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ac =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;VAR c = {"a", "b", "c"}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CALCULATE(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DISTINCTCOUNT(sales[cust_cd]),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FILTER( sales,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RELATED(cust[a]) IN c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; RELATED(cust[s]) IN {"T"}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; [Net Amt] &amp;gt; 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ALL(sales) // This removes filter context on 'sales' for the total row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Result:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Year Month | ac&lt;/P&gt;&lt;P&gt;2023-08&amp;nbsp; &amp;nbsp; &amp;nbsp; | 8186&lt;/P&gt;&lt;P&gt;2023-09&amp;nbsp; &amp;nbsp; &amp;nbsp; | 8125&lt;/P&gt;&lt;P&gt;2023-10&amp;nbsp; &amp;nbsp; &amp;nbsp; | 2815&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Total&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 9227&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still not get the result as per expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 23:31:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3469952#M132485</guid>
      <dc:creator>ChaCha123</dc:creator>
      <dc:date>2023-10-10T23:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix Table Row subtotal different with each row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3469964#M132486</link>
      <description>&lt;P&gt;Hi sir,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, this solution you provided is help! Thank you so much.&lt;/P&gt;&lt;P&gt;Thanks for the shared link.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to change it not using distinctcount.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 23:45:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-Table-Row-subtotal-different-with-each-row/m-p/3469964#M132486</guid>
      <dc:creator>ChaCha123</dc:creator>
      <dc:date>2023-10-10T23:45:37Z</dc:date>
    </item>
  </channel>
</rss>

