<?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: Sum column B by Column A IF the sum of column C by Column A &amp;lt;&amp;gt; 0 in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-column-B-by-Column-A-IF-the-sum-of-column-C-by-Column-A-lt/m-p/3737551#M145709</link>
    <description>&lt;P&gt;To achieve the desired result in Power BI using DAX, you can follow these steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;First, you need to create a new table with the Total Amount for each Job.&lt;/LI&gt;&lt;LI&gt;Then, calculate the Total Retainage for each Job based on the condition where the Total Amount is not equal to 0.&lt;/LI&gt;&lt;LI&gt;Finally, summarize the Total Retainage for those Jobs.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here's how you can write DAX expressions to achieve this:&lt;/P&gt;&lt;P&gt;Assuming you have a table named 'Transactions' with columns Job, Transaction, Amount, and Retainage:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a new table to calculate the Total Amount for each Job:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;TotalAmountPerJob =&lt;BR /&gt;SUMMARIZECOLUMNS (&lt;BR /&gt;'Transactions'[Job],&lt;BR /&gt;"TotalAmount", SUM('Transactions'[Amount])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Create a new table to calculate the Total Retainage for each Job where the Total Amount is not equal to 0:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;TotalRetainagePerJob =&lt;BR /&gt;FILTER (&lt;BR /&gt;ADDCOLUMNS (&lt;BR /&gt;TotalAmountPerJob,&lt;BR /&gt;"TotalRetainage",&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUMX (&lt;BR /&gt;FILTER (&lt;BR /&gt;'Transactions',&lt;BR /&gt;'Transactions'[Job] = EARLIER('Transactions'[Job])&lt;BR /&gt;),&lt;BR /&gt;MAX('Transactions'[Retainage])&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;[TotalAmount] &amp;lt;&amp;gt; 0&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Finally, summarize the Total Retainage for those Jobs:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FinalOutput =&lt;BR /&gt;SUMMARIZE (&lt;BR /&gt;TotalRetainagePerJob,&lt;BR /&gt;'TotalRetainagePerJob'[Job],&lt;BR /&gt;"Retainage", SUM('TotalRetainagePerJob'[TotalRetainage])&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;These DAX expressions should provide you with the desired output where you calculate the Total Retainage for Jobs where the Total Amount is not equal to 0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 02 Mar 2024 10:40:44 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2024-03-02T10:40:44Z</dc:date>
    <item>
      <title>Sum column B by Column A IF the sum of column C by Column A &lt;&gt; 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-column-B-by-Column-A-IF-the-sum-of-column-C-by-Column-A-lt/m-p/3737121#M145675</link>
      <description>&lt;P&gt;OK, I know that subject may look like garbage, but hear me out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of the primary record types for my business is &lt;STRONG&gt;Jobs&lt;/STRONG&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each Job can have multiple &lt;STRONG&gt;Transactions&lt;/STRONG&gt; associated with it.&lt;/P&gt;&lt;P&gt;Each &lt;STRONG&gt;Transaction&lt;/STRONG&gt; will have a dollar value for &lt;STRONG&gt;Amount&lt;/STRONG&gt; and&amp;nbsp;&lt;EM&gt;may&lt;/EM&gt; have a dollar value for &lt;STRONG&gt;Retainage&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Where things get complicated is that the same TransactionID may be associated with the job multiple times.&lt;/P&gt;&lt;P&gt;(Yes, I know the optimal course would be to find what is causing the multiple iterations and filter down to one but all of my support resources are have yet to help me with that)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The goal is:&lt;BR /&gt;When total &lt;STRONG&gt;Amount&lt;/STRONG&gt; for a &lt;STRONG&gt;Job&lt;/STRONG&gt; is not equal to 0 (it may be positive or negative) then&lt;/P&gt;&lt;P&gt;Take the &lt;STRONG&gt;Maximum&lt;/STRONG&gt; &lt;STRONG&gt;Retainage&lt;/STRONG&gt; value for each &lt;STRONG&gt;Transaction&lt;/STRONG&gt; associated with that &lt;STRONG&gt;Job&lt;/STRONG&gt; and add them together so that&lt;/P&gt;&lt;P&gt;We arrive at a &lt;STRONG&gt;Total&lt;/STRONG&gt; &lt;STRONG&gt;Sum&lt;/STRONG&gt; of all &lt;STRONG&gt;Maximum&lt;/STRONG&gt; &lt;STRONG&gt;Retainage&lt;/STRONG&gt; values for all &lt;STRONG&gt;Jobs&lt;/STRONG&gt; where the total &lt;STRONG&gt;Amount&lt;/STRONG&gt; does not equal 0.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I know how I can get the sum of the Amounts per Job.&lt;/P&gt;&lt;P&gt;And I know how I can get the Max value of Retainage for a transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need help with is putting that together so I am adding the max retainage values for all transactions associated wtih a job where the total value of the job &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an exmaple of how the process should work below.&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 21:11:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-column-B-by-Column-A-IF-the-sum-of-column-C-by-Column-A-lt/m-p/3737121#M145675</guid>
      <dc:creator>msimmonds22</dc:creator>
      <dc:date>2024-03-01T21:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sum column B by Column A IF the sum of column C by Column A &lt;&gt; 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-column-B-by-Column-A-IF-the-sum-of-column-C-by-Column-A-lt/m-p/3737550#M145708</link>
      <description>&lt;P&gt;To achieve the desired result in Power BI using DAX, you can follow these steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;First, you need to create a new table with the Total Amount for each Job.&lt;/LI&gt;&lt;LI&gt;Then, calculate the Total Retainage for each Job based on the condition where the Total Amount is not equal to 0.&lt;/LI&gt;&lt;LI&gt;Finally, summarize the Total Retainage for those Jobs.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here's how you can write DAX expressions to achieve this:&lt;/P&gt;&lt;P&gt;Assuming you have a table named 'Transactions' with columns Job, Transaction, Amount, and Retainage:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a new table to calculate the Total Amount for each Job:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;TotalAmountPerJob =&lt;BR /&gt;SUMMARIZECOLUMNS (&lt;BR /&gt;'Transactions'[Job],&lt;BR /&gt;"TotalAmount", SUM('Transactions'[Amount])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Create a new table to calculate the Total Retainage for each Job where the Total Amount is not equal to 0:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;TotalRetainagePerJob =&lt;BR /&gt;FILTER (&lt;BR /&gt;ADDCOLUMNS (&lt;BR /&gt;TotalAmountPerJob,&lt;BR /&gt;"TotalRetainage",&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUMX (&lt;BR /&gt;FILTER (&lt;BR /&gt;'Transactions',&lt;BR /&gt;'Transactions'[Job] = EARLIER('Transactions'[Job])&lt;BR /&gt;),&lt;BR /&gt;MAX('Transactions'[Retainage])&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;[TotalAmount] &amp;lt;&amp;gt; 0&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Finally, summarize the Total Retainage for those Jobs:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FinalOutput =&lt;BR /&gt;SUMMARIZE (&lt;BR /&gt;TotalRetainagePerJob,&lt;BR /&gt;'TotalRetainagePerJob'[Job],&lt;BR /&gt;"Retainage", SUM('TotalRetainagePerJob'[TotalRetainage])&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;These DAX expressions should provide you with the desired output where you calculate the Total Retainage for Jobs where the Total Amount is not equal to 0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2024 10:40:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-column-B-by-Column-A-IF-the-sum-of-column-C-by-Column-A-lt/m-p/3737550#M145708</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-03-02T10:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sum column B by Column A IF the sum of column C by Column A &lt;&gt; 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-column-B-by-Column-A-IF-the-sum-of-column-C-by-Column-A-lt/m-p/3737551#M145709</link>
      <description>&lt;P&gt;To achieve the desired result in Power BI using DAX, you can follow these steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;First, you need to create a new table with the Total Amount for each Job.&lt;/LI&gt;&lt;LI&gt;Then, calculate the Total Retainage for each Job based on the condition where the Total Amount is not equal to 0.&lt;/LI&gt;&lt;LI&gt;Finally, summarize the Total Retainage for those Jobs.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here's how you can write DAX expressions to achieve this:&lt;/P&gt;&lt;P&gt;Assuming you have a table named 'Transactions' with columns Job, Transaction, Amount, and Retainage:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a new table to calculate the Total Amount for each Job:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;TotalAmountPerJob =&lt;BR /&gt;SUMMARIZECOLUMNS (&lt;BR /&gt;'Transactions'[Job],&lt;BR /&gt;"TotalAmount", SUM('Transactions'[Amount])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Create a new table to calculate the Total Retainage for each Job where the Total Amount is not equal to 0:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;TotalRetainagePerJob =&lt;BR /&gt;FILTER (&lt;BR /&gt;ADDCOLUMNS (&lt;BR /&gt;TotalAmountPerJob,&lt;BR /&gt;"TotalRetainage",&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUMX (&lt;BR /&gt;FILTER (&lt;BR /&gt;'Transactions',&lt;BR /&gt;'Transactions'[Job] = EARLIER('Transactions'[Job])&lt;BR /&gt;),&lt;BR /&gt;MAX('Transactions'[Retainage])&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;[TotalAmount] &amp;lt;&amp;gt; 0&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Finally, summarize the Total Retainage for those Jobs:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FinalOutput =&lt;BR /&gt;SUMMARIZE (&lt;BR /&gt;TotalRetainagePerJob,&lt;BR /&gt;'TotalRetainagePerJob'[Job],&lt;BR /&gt;"Retainage", SUM('TotalRetainagePerJob'[TotalRetainage])&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;These DAX expressions should provide you with the desired output where you calculate the Total Retainage for Jobs where the Total Amount is not equal to 0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2024 10:40:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-column-B-by-Column-A-IF-the-sum-of-column-C-by-Column-A-lt/m-p/3737551#M145709</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-03-02T10:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sum column B by Column A IF the sum of column C by Column A &lt;&gt; 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-column-B-by-Column-A-IF-the-sum-of-column-C-by-Column-A-lt/m-p/3739203#M145781</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="699125" data-lia-user-login="msimmonds22" class="lia-mention lia-mention-user"&gt;msimmonds22&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;The answer of &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="403667" data-lia-user-login="123abc" class="lia-mention lia-mention-user"&gt;123abc&lt;/a&gt;&amp;nbsp; is very informative, while I used another method to solve the problem for you. You can follow the steps below:&lt;/P&gt;
&lt;P&gt;1.Add an index column in Power Query.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.Add new columns.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Max Retainage = 
VAR _Rank =
    RANKX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Transaction] = EARLIER ( 'Table'[Transaction] )
        ),
        'Table'[Index],
        ,
        ASC
    )
VAR _MaxRetainage =
    CALCULATE (
        MAX ( 'Table'[Retainage] ),
        FILTER (
            'Table',
            'Table'[Job] = EARLIER ( 'Table'[Job] )
                &amp;amp;&amp;amp; 'Table'[Transaction] = EARLIER ( 'Table'[Transaction] )
        )
    )
RETURN
    IF ( _Rank = 1, _MaxRetainage, 0 )
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Result = 
VAR _Result =
    CALCULATE (
        SUM ( 'Table'[Max Retainage] ),
        FILTER ( 'Table', 'Table'[Job] = EARLIER ( 'Table'[Job] ) )
    )
VAR _TotalAmount =
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        FILTER ( 'Table', 'Table'[Job] = EARLIER ( 'Table'[Job] ) )
    )
RETURN
    IF ( _TotalAmount = 0, 0, _Result )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3.Do not summarize.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Final output:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener"&gt;How to Get Your Question Answered Quickly - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If it does not help, please provide more details with your desired out put and pbix file without privacy information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Ada Wang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;Accept it as the solution&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 07:25:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-column-B-by-Column-A-IF-the-sum-of-column-C-by-Column-A-lt/m-p/3739203#M145781</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-04T07:25:58Z</dc:date>
    </item>
  </channel>
</rss>

