<?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: Loop calculation in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Loop-calculation/m-p/2506123#M69404</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="388256" data-lia-user-login="BCAdmin" class="lia-mention lia-mention-user"&gt;BCAdmin&lt;/a&gt; , Assume you have date or index column (add in power query) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a new column&lt;/P&gt;
&lt;P&gt;[Column1] - Sumx(filter(Table, [Date] &amp;lt;= earlier([date]) ), [Column2] -[Column3])&lt;/P&gt;</description>
    <pubDate>Wed, 11 May 2022 01:45:03 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2022-05-11T01:45:03Z</dc:date>
    <item>
      <title>Loop calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Loop-calculation/m-p/2505823#M69394</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to do this on Power BI, but I can't figure out the formula to do this. I want to use the previous calculated value from Column E to the next row and so on. Is it possible to be done on Power BI?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the formula on Excel:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data value:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 20:53:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Loop-calculation/m-p/2505823#M69394</guid>
      <dc:creator>BCAdmin</dc:creator>
      <dc:date>2022-05-10T20:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Loop calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Loop-calculation/m-p/2506123#M69404</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="388256" data-lia-user-login="BCAdmin" class="lia-mention lia-mention-user"&gt;BCAdmin&lt;/a&gt; , Assume you have date or index column (add in power query) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a new column&lt;/P&gt;
&lt;P&gt;[Column1] - Sumx(filter(Table, [Date] &amp;lt;= earlier([date]) ), [Column2] -[Column3])&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 01:45:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Loop-calculation/m-p/2506123#M69404</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-05-11T01:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Loop calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Loop-calculation/m-p/2512223#M69716</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="388256" data-lia-user-login="BCAdmin" class="lia-mention lia-mention-user"&gt;BCAdmin&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;SPAN class=""&gt;I have a test on amitchandak's code and I find that I won't return the result you want. Firstly, we need to add an Index column in Power Query if you only have month column in text format.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;SPAN class=""&gt;Your table will be like as below.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Then add calculated columns in this table.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column4 = 
VAR _START =
    CALCULATE ( SUM ( 'Table'[Column1] ), ALL ( 'Table' ) )
RETURN
    _START
        + SUMX (
            FILTER ( 'Table', 'Table'[Index] &amp;lt;= EARLIER ( 'Table'[Index] ) ),
            [Column2] - [Column3]
        )&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;New Column1 = 
VAR _PREVIOUS_COLUMN4 =
    CALCULATE (
        SUM ( 'Table'[Column4] ),
        FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 )
    )
RETURN
    IF ( ISBLANK ( 'Table'[Column1] ), _PREVIOUS_COLUMN4, 'Table'[Column1] )&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&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;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 05:48:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Loop-calculation/m-p/2512223#M69716</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-13T05:48:35Z</dc:date>
    </item>
  </channel>
</rss>

