<?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 DAX Sumif Filtered Amount Between Date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Sumif-Filtered-Amount-Between-Date/m-p/3355665#M126093</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I am a novice DAX user struggling to write the equivalent of SUMIF in Excel in DAX. I am currently working with DAX in the Excel Data Model environment. The dataset am I working with is contributions and distributions from/to multiple investors in multiple investments. The data table includes both contributions and distributions. The goal is to ultimately calculate the long-term/short-term nature of gain and loss per investor per investment on a first-in first-out basis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am stuck on calculating the long-term contributions related to a particular(singular) distribution. Long-term contributions are those contributions the occured 366 days before the date of distribution. For example, the long-term contributions for Investor LP0001 in InvA related to the distribution on 2/9/2021 (row 4 below) equals $500,000 ($100,000 contribution on 5/14/209 and $400,000 contribution on 6/7/2019).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a long-term holding date calculated field, but I'm not sure that's even necessary. I'm open to all options.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.dropbox.com/scl/fo/dcwqqkqaazd0n62krmyrr/h?rlkey=9dbpcvdbz7o5yiyfc4ohejz9f&amp;amp;dl=0" target="_self"&gt;Link to Sample Data&lt;/A&gt;&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, 28 Jul 2023 15:48:52 GMT</pubDate>
    <dc:creator>Buckeye_Amy</dc:creator>
    <dc:date>2023-07-28T15:48:52Z</dc:date>
    <item>
      <title>DAX Sumif Filtered Amount Between Date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Sumif-Filtered-Amount-Between-Date/m-p/3355665#M126093</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I am a novice DAX user struggling to write the equivalent of SUMIF in Excel in DAX. I am currently working with DAX in the Excel Data Model environment. The dataset am I working with is contributions and distributions from/to multiple investors in multiple investments. The data table includes both contributions and distributions. The goal is to ultimately calculate the long-term/short-term nature of gain and loss per investor per investment on a first-in first-out basis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am stuck on calculating the long-term contributions related to a particular(singular) distribution. Long-term contributions are those contributions the occured 366 days before the date of distribution. For example, the long-term contributions for Investor LP0001 in InvA related to the distribution on 2/9/2021 (row 4 below) equals $500,000 ($100,000 contribution on 5/14/209 and $400,000 contribution on 6/7/2019).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a long-term holding date calculated field, but I'm not sure that's even necessary. I'm open to all options.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.dropbox.com/scl/fo/dcwqqkqaazd0n62krmyrr/h?rlkey=9dbpcvdbz7o5yiyfc4ohejz9f&amp;amp;dl=0" target="_self"&gt;Link to Sample Data&lt;/A&gt;&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, 28 Jul 2023 15:48:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Sumif-Filtered-Amount-Between-Date/m-p/3355665#M126093</guid>
      <dc:creator>Buckeye_Amy</dc:creator>
      <dc:date>2023-07-28T15:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Sumif Filtered Amount Between Date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Sumif-Filtered-Amount-Between-Date/m-p/3356855#M126164</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="595763" data-lia-user-login="Buckeye_Amy" class="lia-mention lia-mention-user"&gt;Buckeye_Amy&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The equivalent of Excel SUMIF in DAX is a combination of SUMX and FILTER. The following measure solves your requirement based on the table structure provided on sheet "Data" in your Excel file:&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;Long Term Contributions = 
VAR _LongtermContributionsDaysOffset = 366

VAR _AmountOfLongTermContributions =
    ADDCOLUMNS (
        CALCULATETABLE (
            SUMMARIZECOLUMNS (
                'Data'[InvestorNo],
                'Data'[Investment],
                'Data'[InvestTranDate]
            ),
            KEEPFILTERS ( 'Data'[InvestTranType] = "Distribution" )
        ),
        "@AmountOfLongTermContributions",
        SUMX (
            FILTER (
                ALL ( 'Data' ),
                'Data'[InvestorNo] = EARLIER ( [InvestorNo] ) &amp;amp;&amp;amp;
                'Data'[Investment] = EARLIER ( [Investment] ) &amp;amp;&amp;amp;
                'Data'[InvestTranDate] &amp;lt;= EARLIER ( [InvestTranDate] ) - _LongtermContributionsDaysOffset + 1 &amp;amp;&amp;amp;
                'Data'[InvestTranType] = "Contribution"
            ),
            [TranAmount]
        )
    )
RETURN
SUMX ( _AmountOfLongTermContributions, [@AmountOfLongTermContributions] )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The part replacing the SUMIF is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;SUMX&lt;/STRONG&gt; (&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;FILTER&lt;/STRONG&gt; (&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ALL ( 'Data' ),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Data'[InvestorNo] = EARLIER ( [InvestorNo] ) &amp;amp;&amp;amp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Data'[Investment] = EARLIER ( [Investment] ) &amp;amp;&amp;amp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Data'[InvestTranDate] &amp;lt;= EARLIER ( [InvestTranDate] ) - _LongtermContributionsDaysOffset + 1&lt;SPAN&gt;&amp;nbsp;&amp;amp;&amp;amp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'Data'&lt;/SPAN&gt;&lt;SPAN&gt;[InvestTranType]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"Contribution"&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; ),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; [TranAmount]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result looks like (. and , will switch based on locale settings):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can download the file here: &lt;A title="sumif.pbix" href="https://github.com/MartinBubenheimer/powerbi-solutions/raw/main/community-solutions/sumif/sumif.pbix" target="_self"&gt;sumif.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;P class="lia-align-right"&gt;&lt;A title="GitHub" href="https://github.com/MartinBubenheimer" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&lt;A title="linkedin" href="https://www.linkedin.com/in/martin-bubenheimer-9ba99271/" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jul 2023 15:08:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Sumif-Filtered-Amount-Between-Date/m-p/3356855#M126164</guid>
      <dc:creator>Martin_D</dc:creator>
      <dc:date>2023-07-30T15:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Sumif Filtered Amount Between Date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Sumif-Filtered-Amount-Between-Date/m-p/3364016#M126478</link>
      <description>&lt;P&gt;Martin: Thank you for your help! This solution worked!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 16:19:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Sumif-Filtered-Amount-Between-Date/m-p/3364016#M126478</guid>
      <dc:creator>Buckeye_Amy</dc:creator>
      <dc:date>2023-08-03T16:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Sumif Filtered Amount Between Date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Sumif-Filtered-Amount-Between-Date/m-p/3364237#M126493</link>
      <description>&lt;P&gt;Hi Martin,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Quick follow-up. It appears that this solution may be causing circular dependency issues in subsequent calucated columns. Are there any changes we can make to the DAX to prevent circular issues?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 19:21:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Sumif-Filtered-Amount-Between-Date/m-p/3364237#M126493</guid>
      <dc:creator>Buckeye_Amy</dc:creator>
      <dc:date>2023-08-03T19:21:04Z</dc:date>
    </item>
  </channel>
</rss>

