<?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: Opening and Closing Stock Calculation with Purchase 1 &amp;amp; 2 in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4631280#M177318</link>
    <description>&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp; Thank you for your response.&lt;/P&gt;&lt;P class=""&gt;To clarify, &lt;STRONG&gt;exhausted&lt;/STRONG&gt; means that the closing stock should equal the sum of Purchase Qty1 and Sales Qty.&lt;BR /&gt;For example:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;In 2024, for Biala 1.5L:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Closing Stock = -100 (Sales Qty) + 80 (Purchase Qty1) = -20.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Since the value is negative, it indicates that Purchase Qty1 is exhausted, and the remaining 20 should be taken from Purchase Qty2.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;The sample data provided is fine.&lt;/P&gt;</description>
    <pubDate>Mon, 31 Mar 2025 09:10:35 GMT</pubDate>
    <dc:creator>Pavan_123456789</dc:creator>
    <dc:date>2025-03-31T09:10:35Z</dc:date>
    <item>
      <title>Opening and Closing Stock Calculation with Purchase 1 &amp; 2</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4629661#M177236</link>
      <description>&lt;H3&gt;&lt;STRONG&gt;Power Bi File&amp;nbsp; Link :-&lt;/STRONG&gt;&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1seE1akFGXcAGRF40_WHnxQpzeWMSrWCT/view?usp=drive_link" target="_blank"&gt;https://drive.google.com/file/d/1seE1akFGXcAGRF40_WHnxQpzeWMSrWCT/view?usp=drive_link&lt;/A&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Context:&lt;/STRONG&gt;&lt;/H3&gt;&lt;P class=""&gt;&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt;I am calculating &lt;STRONG&gt;Opening Stock and Closing Stock&lt;/STRONG&gt; for each year and item (Account.3), considering:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Purchase Qty 1 — Primary stock to use for sales.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Purchase Qty 2 — Backup stock if Purchase Qty 1 is exhausted.&lt;/P&gt;&lt;H2&gt;&lt;span class="lia-unicode-emoji" title=":fire:"&gt;🔥&lt;/span&gt;&lt;STRONG&gt;🧩 Requirements:&lt;/STRONG&gt;&lt;/H2&gt;&lt;/LI&gt;&lt;LI&gt;&lt;H2&gt;&amp;nbsp;&lt;/H2&gt;&lt;H3&gt;&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt;&lt;STRONG&gt;Opening_Stock1&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Gets value from the &lt;STRONG&gt;previous year’s Closing_Stock1&lt;/STRONG&gt;.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;If no previous year’s data, it should be 0.&lt;BR /&gt;--------------------------------------------------------------------------------------&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt;&lt;STRONG&gt;Closing_Stock1&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Formula:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Closing_Stock1=Opening_Stock1+Purchase&amp;nbsp;Qty&amp;nbsp;1+Sales&amp;nbsp;Qty&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;If Sales Qty is more than available stock in Purchase Qty 1, the &lt;STRONG&gt;excess sales&lt;/STRONG&gt; will be deducted from Purchase Qty 2.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;--------------------------------------------------------------------------&lt;/P&gt;&lt;H3&gt;&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt;&lt;STRONG&gt;Opening_Stock2&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Gets value from the &lt;STRONG&gt;previous year’s Closing_Stock2&lt;/STRONG&gt;.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;If no previous year’s data, it should be 0.------------------------------------------------------------------------------------&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;&lt;STRONG&gt;Closing_Stock2&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Deducts &lt;STRONG&gt;excess sales&lt;/STRONG&gt; from Purchase Qty 2 after Purchase Qty 1 is exhausted.&lt;BR /&gt;&lt;BR /&gt;Expected Result&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;img /&gt;&lt;P&gt;I tried this measures but not working one or two values not getting properly in opening stock1&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;STRONG&gt;Opening_Stock 1&lt;/STRONG&gt;=&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;PrevYear&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Year]&lt;/SPAN&gt;&lt;SPAN&gt;) - &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;-- Find the latest available Closing Stock from previous years&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;PrevClosingStock&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Purchase Qty 1]&lt;/SPAN&gt;&lt;SPAN&gt;) - &lt;/SPAN&gt;&lt;SPAN&gt;ABS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Sales Qty]&lt;/SPAN&gt;&lt;SPAN&gt;)),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;), &amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Year]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;PrevYear&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;-- Track all past years, not just one&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Account.3]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Account.3]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;PrevClosingStock&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;PrevClosingStock&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;STRONG&gt;Closing_Stock1&lt;/STRONG&gt; = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; OpeningStock = [Opening_Stock] &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;-- Now using the corrected Opening Stock&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; SalesQty = &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;('Table'[Sales Qty])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; PurchaseQty = &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;('Table'[Purchase Qty 1])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;SPAN&gt; OpeningStock + PurchaseQty + SalesQty&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 28 Mar 2025 16:48:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4629661#M177236</guid>
      <dc:creator>Pavan_123456789</dc:creator>
      <dc:date>2025-03-28T16:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Opening and Closing Stock Calculation with Purchase 1 &amp; 2</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4629770#M177241</link>
      <description>&lt;P&gt;Your sample data doesn't cover the scenarios&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;
&lt;P&gt;Purchase Qty1 is never exhausted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide more realistic sample data.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2025 17:57:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4629770#M177241</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2025-03-28T17:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Opening and Closing Stock Calculation with Purchase 1 &amp; 2</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4631280#M177318</link>
      <description>&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp; Thank you for your response.&lt;/P&gt;&lt;P class=""&gt;To clarify, &lt;STRONG&gt;exhausted&lt;/STRONG&gt; means that the closing stock should equal the sum of Purchase Qty1 and Sales Qty.&lt;BR /&gt;For example:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;In 2024, for Biala 1.5L:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Closing Stock = -100 (Sales Qty) + 80 (Purchase Qty1) = -20.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Since the value is negative, it indicates that Purchase Qty1 is exhausted, and the remaining 20 should be taken from Purchase Qty2.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;The sample data provided is fine.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 09:10:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4631280#M177318</guid>
      <dc:creator>Pavan_123456789</dc:creator>
      <dc:date>2025-03-31T09:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Opening and Closing Stock Calculation with Purchase 1 &amp; 2</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4631662#M177334</link>
      <description>&lt;LI-CODE lang="markup"&gt;Since the value is negative, it indicates that Purchase Qty1 is exhausted, and the remaining 20 should be taken from Purchase Qty2.&lt;/LI-CODE&gt;
&lt;P&gt;I am not aware of a method in DAX to do conditional accumulation.&amp;nbsp; Your only option is List.Accumulate in Power Query.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 14:13:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4631662#M177334</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2025-03-31T14:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Opening and Closing Stock Calculation with Purchase 1 &amp; 2</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4633581#M177391</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Could you please suggest me how to do in power Query?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 14:55:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4633581#M177391</guid>
      <dc:creator>Pavan_123456789</dc:creator>
      <dc:date>2025-04-01T14:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Opening and Closing Stock Calculation with Purchase 1 &amp; 2</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4635022#M177445</link>
      <description>&lt;P&gt;Here's the general idea. You would have to do similar code for all four columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// Table
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDS9UrM0zUyUdJR0jUyAJJOmYk5iQqGPkCmoYEBlIzViQbSSEoN8Ss1QzbVGJ9SIzMUU5GM1TMFqbZAUWyJpNgMn7FAf7mlJukamRLlL4RSQwwHGJqi+QzJXEI+Qyg1IeBYsLfM8DjWFDUSzHA4Fms0mKM7FofPsCvGVAqLMws0n2FzAyzKLHBGmTFIZSwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Qty = _t, Account.3 = _t, #"Maspex Biala" = _t, #"Roust Biala" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Qty", Int64.Type}, {"Account.3", type text}, {"Maspex Biala", Int64.Type}, {"Roust Biala", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Maspex Biala", "Purchase Qty1"}, {"Roust Biala", "Purchase qty 2"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Year", each Date.Year([Date]),Int64.Type),
    #"Grouped Rows" = Table.Group(#"Added Custom", { "Account.3","Year"}, {{"Purchase Qty 1", each List.Average([Purchase Qty1]), type nullable number}, {"Purchase Qty 2", each List.Average([Purchase qty 2]), type nullable number}, {"Sales Qty", each List.Sum([Qty]), type nullable number}}),
    #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Account.3", Order.Ascending}, {"Year", Order.Ascending}}),
    #"Added Custom1" = Table.AddColumn(
  #"Sorted Rows", 
  "Open Stock 1", 
  (k) =&amp;gt;
    let
      years = Table.SelectRows(
        #"Sorted Rows", 
        each [Account.3] = k[Account.3] and [Year] &amp;lt; k[Year]
      )[Year]
    in
      List.Accumulate(
        years, 
        0, 
        (s, c) =&amp;gt;
          if List.Count(years) = 0 then
            s
          else 
            let
              curryear = Table.SelectRows(
                    #"Sorted Rows", 
                    each [Account.3] = k[Account.3] and [Year] = c 
                  ){0}
            in //List.Sum(curryear[Purchase Qty 1])
              if s + curryear[Purchase Qty 1] - curryear[Sales Qty] &amp;gt;= 0
              then s + curryear[Purchase Qty 1] - curryear[Sales Qty] 
              else s + curryear[Purchase Qty 1] + curryear[Purchase Qty 2] - curryear[Sales Qty] 
      )
)
in
    #"Added Custom1"&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Apr 2025 12:04:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4635022#M177445</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2025-04-02T12:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Opening and Closing Stock Calculation with Purchase 1 &amp; 2</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4641005#M177707</link>
      <description>&lt;P&gt;Hi&lt;SPAN&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="658720" data-lia-user-login="Pavan_123456789" class="lia-mention lia-mention-user"&gt;Pavan_123456789&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/100342" target="_blank" rel="noopener"&gt;@lbendlin&lt;/A&gt;&amp;nbsp;for Addressing the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.&lt;BR /&gt;If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Chaithanya.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Apr 2025 11:55:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4641005#M177707</guid>
      <dc:creator>v-kathullac</dc:creator>
      <dc:date>2025-04-07T11:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Opening and Closing Stock Calculation with Purchase 1 &amp; 2</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4648608#M177943</link>
      <description>&lt;P&gt;Hi&lt;SPAN&gt;&amp;nbsp;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/658720" target="_blank"&gt;@Pavan_123456789&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/100342" target="_blank" rel="noopener"&gt;@lbendlin&lt;/A&gt;&amp;nbsp;for Addressing the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.&lt;BR /&gt;If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Chaithanya.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 11:41:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4648608#M177943</guid>
      <dc:creator>v-kathullac</dc:creator>
      <dc:date>2025-04-11T11:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Opening and Closing Stock Calculation with Purchase 1 &amp; 2</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4657916#M178348</link>
      <description>&lt;P&gt;Hi&lt;SPAN&gt;&amp;nbsp;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/658720" target="_blank"&gt;@Pavan_123456789&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/100342" target="_blank" rel="noopener"&gt;@lbendlin&lt;/A&gt;&amp;nbsp;for Addressing the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.&lt;BR /&gt;If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Chaithanya.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Apr 2025 16:03:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Opening-and-Closing-Stock-Calculation-with-Purchase-1-amp-2/m-p/4657916#M178348</guid>
      <dc:creator>v-kathullac</dc:creator>
      <dc:date>2025-04-17T16:03:43Z</dc:date>
    </item>
  </channel>
</rss>

