<?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: Help with DAX for Running Total Subtractions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-for-Running-Total-Subtractions/m-p/4423366#M175601</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937082" data-lia-user-login="bibro5" class="lia-mention lia-mention-user"&gt;bibro5&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for providing the sample data. It would have been beneficial to increase the number of rows in the "Transactions" table and include an expected outcome based that data. Nevertheless, I added additional data to the "Transactions" table to validate edge cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "Transaction" table I created is as follows:&lt;/P&gt;
&lt;TABLE border="1" width="99.8768472906404%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;DATE&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;ID&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;Quantity sold&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-01&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;2&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-03&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;2&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-04&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;1&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-05&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-06&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-07&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-08&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;4&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-09&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;4&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-10&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-11&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;1&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-12&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;1&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-13&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;1&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-14&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-15&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The relationship between the 2 tables are as follows:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the two initial simple measures I have developed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To calculate the total quantity sold from the "Transactions" table:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Total Quantity Sold =
SUM ( Transactions[Quantity sold] )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To calculate/reference the available quantity from the "Inventory" table:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Available Quantity =
IF ( [Total Quantity Sold] &amp;lt;&amp;gt; BLANK (), MAX ( Inventory[Quantity] ) )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the measure I have created that calculated the "Running Subtraction" of quantity based on their availability in the inventory:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Running Quantity Sold = 
VAR _remainingQty =
    CALCULATE (
        [Available Quantity] - [Total Quantity Sold],
        FILTER (
            ALL ( Transactions ),
            Transactions[ID] = MAX ( Transactions[ID] )
                &amp;amp;&amp;amp; Transactions[DATE] &amp;lt;= MAX ( Transactions[DATE] )
        )
    )
VAR _runningQuntity =
    IF (
        _remainingQty &amp;gt;= 0,
        [Total Quantity Sold],
        [Total Quantity Sold] + _remainingQty
    )
VAR _handlingOversale =
    IF (
        _runningQuntity &amp;lt;= 0
            &amp;amp;&amp;amp; [Total Quantity Sold] &amp;lt;&amp;gt; BLANK (),
        0,
        _runningQuntity
    )
RETURN
    _handlingOversale
&lt;/LI-CODE&gt;
&lt;P&gt;Here is the screenshot of the measure along with the result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you see, for "oranges," on January 10th, the quantity sold is 7, but in Inventory, only 1 item remains. Therefore, it shows 1 instead of 7 (ignores the remaining 6). Additionally, if any sales for "oranges" are found afterward, since we have none in inventory it shows 0.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;I am attaching the Power BI file for your reference. Please review the results and, and inform me if you have any further queries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Udit&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accepting it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;Appreciate your Kudo &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":rocket:"&gt;🚀&lt;/span&gt; Let's Connect: &lt;A href="https://www.linkedin.com/in/quantumudit/" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;LinkedIn&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://www.youtube.com/@quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;YouTube&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://medium.com/@quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;Medium&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://github.com/quantumudit/" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;GitHub&lt;/STRONG&gt;&lt;/A&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":sparkles:"&gt;✨&lt;/span&gt; Visit My Linktree: &lt;A href="https://linktr.ee/quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;LinkTree&lt;/STRONG&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG style="color: #033f38;"&gt;Proud to be a Super User&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 23 Feb 2025 08:01:17 GMT</pubDate>
    <dc:creator>quantumudit</dc:creator>
    <dc:date>2025-02-23T08:01:17Z</dc:date>
    <item>
      <title>Help with DAX for Running Total Subtractions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-for-Running-Total-Subtractions/m-p/4423156#M175593</link>
      <description>&lt;P&gt;I'm working with two tables, **Inventory** and **Transactions**, and I'm trying to create a DAX measure that provides a running total of subtractions. Here's the scenario:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Inventory&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Type&lt;/TD&gt;&lt;TD&gt;Quantity&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;apples&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;bananas&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;oranges&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;grapes&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;transactions&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DATE&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Quantity sold&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2025&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/3/2025&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/4/2025&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/5/2025&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;In the example, there are 5 bananas sold over the first two days. Since the inventory quantity is 3, I need to show 2 bananas sold on 1/1/2025 and 1 banana sold on 1/3/2025. The remaining transaction on 1/3/2025 should not be counted since there would have only been 3 bananas in inventory.&lt;/P&gt;&lt;P&gt;My goal is to stop counting item transactions once the inventory runs out. How can I write the DAX measures to achieve this?&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2025 17:57:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-for-Running-Total-Subtractions/m-p/4423156#M175593</guid>
      <dc:creator>bibro5</dc:creator>
      <dc:date>2025-02-22T17:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with DAX for Running Total Subtractions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-for-Running-Total-Subtractions/m-p/4423366#M175601</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937082" data-lia-user-login="bibro5" class="lia-mention lia-mention-user"&gt;bibro5&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for providing the sample data. It would have been beneficial to increase the number of rows in the "Transactions" table and include an expected outcome based that data. Nevertheless, I added additional data to the "Transactions" table to validate edge cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "Transaction" table I created is as follows:&lt;/P&gt;
&lt;TABLE border="1" width="99.8768472906404%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;DATE&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;ID&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;Quantity sold&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-01&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;2&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-03&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;2&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-04&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;1&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-05&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-06&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-07&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-08&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;4&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-09&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;4&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-10&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-11&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;1&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-12&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;1&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-13&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;1&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-14&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="32.51231527093596%"&gt;2025-01-15&lt;/TD&gt;
&lt;TD width="28.201970443349754%"&gt;3&lt;/TD&gt;
&lt;TD width="39.16256157635468%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The relationship between the 2 tables are as follows:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the two initial simple measures I have developed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To calculate the total quantity sold from the "Transactions" table:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Total Quantity Sold =
SUM ( Transactions[Quantity sold] )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To calculate/reference the available quantity from the "Inventory" table:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Available Quantity =
IF ( [Total Quantity Sold] &amp;lt;&amp;gt; BLANK (), MAX ( Inventory[Quantity] ) )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the measure I have created that calculated the "Running Subtraction" of quantity based on their availability in the inventory:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Running Quantity Sold = 
VAR _remainingQty =
    CALCULATE (
        [Available Quantity] - [Total Quantity Sold],
        FILTER (
            ALL ( Transactions ),
            Transactions[ID] = MAX ( Transactions[ID] )
                &amp;amp;&amp;amp; Transactions[DATE] &amp;lt;= MAX ( Transactions[DATE] )
        )
    )
VAR _runningQuntity =
    IF (
        _remainingQty &amp;gt;= 0,
        [Total Quantity Sold],
        [Total Quantity Sold] + _remainingQty
    )
VAR _handlingOversale =
    IF (
        _runningQuntity &amp;lt;= 0
            &amp;amp;&amp;amp; [Total Quantity Sold] &amp;lt;&amp;gt; BLANK (),
        0,
        _runningQuntity
    )
RETURN
    _handlingOversale
&lt;/LI-CODE&gt;
&lt;P&gt;Here is the screenshot of the measure along with the result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you see, for "oranges," on January 10th, the quantity sold is 7, but in Inventory, only 1 item remains. Therefore, it shows 1 instead of 7 (ignores the remaining 6). Additionally, if any sales for "oranges" are found afterward, since we have none in inventory it shows 0.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;I am attaching the Power BI file for your reference. Please review the results and, and inform me if you have any further queries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Udit&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accepting it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;Appreciate your Kudo &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":rocket:"&gt;🚀&lt;/span&gt; Let's Connect: &lt;A href="https://www.linkedin.com/in/quantumudit/" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;LinkedIn&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://www.youtube.com/@quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;YouTube&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://medium.com/@quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;Medium&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://github.com/quantumudit/" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;GitHub&lt;/STRONG&gt;&lt;/A&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":sparkles:"&gt;✨&lt;/span&gt; Visit My Linktree: &lt;A href="https://linktr.ee/quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;LinkTree&lt;/STRONG&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG style="color: #033f38;"&gt;Proud to be a Super User&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2025 08:01:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-for-Running-Total-Subtractions/m-p/4423366#M175601</guid>
      <dc:creator>quantumudit</dc:creator>
      <dc:date>2025-02-23T08:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help with DAX for Running Total Subtractions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-for-Running-Total-Subtractions/m-p/4423586#M175608</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="219243" data-lia-user-login="quantumudit" class="lia-mention lia-mention-user"&gt;quantumudit&lt;/a&gt;&amp;nbsp;thank you with your reply and you are correct. I could have been more descriptive on what I wanted the outcome to be.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my example, I don't want to use a slicer for each individual item. I want it to look like my screenshot. The only issue is the total for running quantity sold is greater than available quantity. can you help me fix this?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2025 22:37:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-for-Running-Total-Subtractions/m-p/4423586#M175608</guid>
      <dc:creator>bibro5</dc:creator>
      <dc:date>2025-02-23T22:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help with DAX for Running Total Subtractions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-for-Running-Total-Subtractions/m-p/4545723#M175629</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937082" data-lia-user-login="bibro5" class="lia-mention lia-mention-user"&gt;bibro5&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To obtain the correct row totals, we modify the formulas as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Modify the "Available Quantity" formula as follows:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Available Quantity =
IF ( [Total Quantity Sold] &amp;lt;&amp;gt; BLANK (), SUM ( Inventory[Quantity] ) )
&lt;/LI-CODE&gt;
&lt;P&gt;Modify the "Running Quantity Sold" formula as follows:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Running Quantity Sold = 
VAR _remainingQty =
    CALCULATE (
        [Available Quantity] - [Total Quantity Sold],
        FILTER (
            ALL ( Transactions ),
            Transactions[ID] = MAX ( Transactions[ID] )
                &amp;amp;&amp;amp; Transactions[DATE] &amp;lt;= MAX ( Transactions[DATE] )
        )
    )
VAR _runningQuntity =
    IF (
        _remainingQty &amp;gt;= 0,
        [Total Quantity Sold],
        [Total Quantity Sold] + _remainingQty
    )
VAR _handlingOversale =
    IF (
        _runningQuntity &amp;lt;= 0
            &amp;amp;&amp;amp; [Total Quantity Sold] &amp;lt;&amp;gt; BLANK (),
        0,
        _runningQuntity
    )

RETURN
    IF(ISINSCOPE(Transactions[DATE]), _handlingOversale, [Available Quantity])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the following animation, you can observe that we are achieving the desired results at both the total level and the individual ID/Type leve. While I understand you do not wish any slicer, please note that the formula is robust to handle it should you decide to utilize one in the future.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am also attaching the Power BI file for your reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope have answered your question correctly. However, if there is still any doubt, please do not hesitate to let me know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Udit&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accepting it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;Appreciate your Kudo &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":rocket:"&gt;🚀&lt;/span&gt; Let's Connect: &lt;A href="https://www.linkedin.com/in/quantumudit/" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;LinkedIn&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://www.youtube.com/@quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;YouTube&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://medium.com/@quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;Medium&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://github.com/quantumudit/" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;GitHub&lt;/STRONG&gt;&lt;/A&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":sparkles:"&gt;✨&lt;/span&gt; Visit My Linktree: &lt;A href="https://linktr.ee/quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;LinkTree&lt;/STRONG&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG style="color: #033f38;"&gt;Proud to be a Super User&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2025 17:56:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-for-Running-Total-Subtractions/m-p/4545723#M175629</guid>
      <dc:creator>quantumudit</dc:creator>
      <dc:date>2025-02-24T17:56:15Z</dc:date>
    </item>
  </channel>
</rss>

