<?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: dax problem: subtract multiple values in same column based on DATE and filter and get final values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103463#M162829</link>
    <description>&lt;P&gt;thank you for your reply&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;15735 is from C4+C8 (1922+13813, group by order_no and date, it's shipped on 6/19 )&lt;/P&gt;&lt;P&gt;and total instock qty group by order no , for example , A24040025 is&amp;nbsp; 22281 , and&amp;nbsp; all schedule ship qty is 30878+4122=35000&lt;/P&gt;&lt;P&gt;so 35000-22281=12719 (as final_unshipped_qty, and date need to use max schedule_ship_date, so it belongs to December)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;why the qty of A240600046 and A24070041 are marked in green, they have different order_no, which is different from the other calculation logic. &amp;gt;&amp;gt;&amp;gt;&amp;gt; It's all instocked in July (2182=213+1+1098+2+868), the result BI table will show instocked_qty and final_unshipped_qty by year/month&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Similarly,&amp;nbsp;we can get total instocked_qty in June is 15735, in May is 6546 (c23+c24+c25) and we don't have instocked_qty in Auguest.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Aug 2024 03:49:05 GMT</pubDate>
    <dc:creator>iamjoy</dc:creator>
    <dc:date>2024-08-16T03:49:05Z</dc:date>
    <item>
      <title>dax problem: subtract multiple values in same column based on DATE and filter and get final values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4099255#M162671</link>
      <description>&lt;P&gt;&lt;SPAN&gt;raw date is from A~D&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to get final unshipping quantity and Cumulative quantity (L &amp;amp; M column) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but I can't find perfect solution to solve this problem&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;K5 = C2+C3(=35000) - C5( first time instock group by order no )&lt;/P&gt;&lt;P&gt;K7 = K5-C7( second time instock group by order no )&lt;/P&gt;&lt;P&gt;K6 = K7-C6( third time instock group by order no )&lt;/P&gt;&lt;P&gt;K4= K6-(C4+C8)&amp;nbsp;( foruth time instock group by order no and it has 2 times&amp;nbsp; "instock" in one day )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;L4 = total scheduled_qty - total instock_qty (35000-22281)&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;order_no&lt;/TD&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;QTY&lt;/TD&gt;&lt;TD&gt;type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24040025&lt;/TD&gt;&lt;TD&gt;2024/5/13&lt;/TD&gt;&lt;TD&gt;30878&lt;/TD&gt;&lt;TD&gt;schedule_ship_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24040025&lt;/TD&gt;&lt;TD&gt;2024/12/31&lt;/TD&gt;&lt;TD&gt;4122&lt;/TD&gt;&lt;TD&gt;schedule_ship_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24040025&lt;/TD&gt;&lt;TD&gt;2024/6/19&lt;/TD&gt;&lt;TD&gt;1922&lt;/TD&gt;&lt;TD&gt;instock_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24040025&lt;/TD&gt;&lt;TD&gt;2024/5/3&lt;/TD&gt;&lt;TD&gt;4196&lt;/TD&gt;&lt;TD&gt;instock_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24040025&lt;/TD&gt;&lt;TD&gt;2024/5/20&lt;/TD&gt;&lt;TD&gt;2335&lt;/TD&gt;&lt;TD&gt;instock_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24040025&lt;/TD&gt;&lt;TD&gt;2024/5/15&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;instock_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24040025&lt;/TD&gt;&lt;TD&gt;2024/6/19&lt;/TD&gt;&lt;TD&gt;13813&lt;/TD&gt;&lt;TD&gt;instock_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24070109&lt;/TD&gt;&lt;TD&gt;2024/8/21&lt;/TD&gt;&lt;TD&gt;4000&lt;/TD&gt;&lt;TD&gt;schedule_ship_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24060046&lt;/TD&gt;&lt;TD&gt;2024/7/12&lt;/TD&gt;&lt;TD&gt;1323&lt;/TD&gt;&lt;TD&gt;schedule_ship_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24060046&lt;/TD&gt;&lt;TD&gt;2024/7/30&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;instock_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24060046&lt;/TD&gt;&lt;TD&gt;2024/7/29&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;instock_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24060046&lt;/TD&gt;&lt;TD&gt;2024/7/30&lt;/TD&gt;&lt;TD&gt;212&lt;/TD&gt;&lt;TD&gt;instock_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A24060046&lt;/TD&gt;&lt;TD&gt;2024/7/19&lt;/TD&gt;&lt;TD&gt;1098&lt;/TD&gt;&lt;TD&gt;instock_date&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 14 Aug 2024 06:12:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4099255#M162671</guid>
      <dc:creator>iamjoy</dc:creator>
      <dc:date>2024-08-14T06:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: dax problem: subtract multiple values in same column based on DATE and filter and get final values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4101860#M162766</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="791279" data-lia-user-login="iamjoy" class="lia-mention lia-mention-user"&gt;iamjoy&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can try the following dax to achieve your need.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;DAX:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;final_unshipped_qty = 
VAR CurrentIndex = 'Table'[Index]
VAR PreviousIndex = CurrentIndex - 1
VAR CurrentOrderNo = 'Table'[order_no]
VAR PreviousType =
    CALCULATE (
        MAX ( 'Table'[type] ),
        FILTER ( 'Table', 'Table'[Index] = PreviousIndex )
    )
VAR PreviousFinalUnshippedQty =
    CALCULATE (
        MAX ( 'Table'[sumQTY By OrderNo and type] ),
        FILTER ( 'Table', 'Table'[Index] = PreviousIndex )
    )
VAR _result1 =
    IF (
        CurrentOrderNo
            = CALCULATE (
                MAX ( 'Table'[order_no] ),
                FILTER ( 'Table', 'Table'[Index] = PreviousIndex )
            )
            &amp;amp;&amp;amp; 'Table'[type] &amp;lt;&amp;gt; PreviousType,
        PreviousFinalUnshippedQty - 'Table'[sumQTY By OrderNo and type],
        BLANK ()
    )
VAR _orderCount =
    CALCULATE (
        COUNT ( 'Table'[order_no] ),
        FILTER ( 'Table', 'Table'[order_no] = CurrentOrderNo )
    )
VAR _result2 =
    IF ( _orderCount = 1, CALCULATE ( MAX ( 'Table'[QTY] ) ) )
RETURN
    _result1 + _result2
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C01%7Cv-yaningyang%40microsoft.com%7Cce16d19809414d9f960208dbf1755128%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638369258411601530%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=oBisEpJnsk4p%2BcSV0F8sZ%2BFQHR%2FRvYA8sUWZIEcjQ4o%3D&amp;amp;reserved=0" target="_blank"&gt;How to get your questions answered quickly&lt;/A&gt;&amp;nbsp;--&amp;nbsp;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-provide-sample-data-in-the-Power-BI-Forum%2Fba-p%2F963216&amp;amp;data=05%7C01%7Cv-yaningyang%40microsoft.com%7Cce16d19809414d9f960208dbf1755128%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638369258411609718%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=sCaEt5xd5uTLXCby0%2B1XhR9V7RXxZLDCF088%2F9u%2FOUU%3D&amp;amp;reserved=0" target="_blank"&gt;&amp;nbsp;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 07:55:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4101860#M162766</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-15T07:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: dax problem: subtract multiple values in same column based on DATE and filter and get final values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103294#M162820</link>
      <description>&lt;P&gt;thank you so much&lt;/P&gt;&lt;P&gt;but I need 'final_unshipped_qty'&amp;nbsp; and 'date' column like this&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 02:07:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103294#M162820</guid>
      <dc:creator>iamjoy</dc:creator>
      <dc:date>2024-08-16T02:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: dax problem: subtract multiple values in same column based on DATE and filter and get final values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103312#M162821</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="791279" data-lia-user-login="iamjoy" class="lia-mention lia-mention-user"&gt;iamjoy&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Do you mean to regenerate a table with only the dates marked yellow and the corresponding final_unshipped_qty values?&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yang&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Community Support Team&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 02:09:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103312#M162821</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-16T02:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: dax problem: subtract multiple values in same column based on DATE and filter and get final values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103342#M162822</link>
      <description>&lt;P&gt;result BI table like this&lt;/P&gt;&lt;P&gt;so I think what i need from raw data to A21~D21 table is right?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 02:21:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103342#M162822</guid>
      <dc:creator>iamjoy</dc:creator>
      <dc:date>2024-08-16T02:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: dax problem: subtract multiple values in same column based on DATE and filter and get final values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103373#M162824</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="791279" data-lia-user-login="iamjoy" class="lia-mention lia-mention-user"&gt;iamjoy&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Sorry, still can't see what you need, does the table you want refer to all the data in rows 21-34 or rows 21, 22, 27, 28, 32.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yang&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Community Support Team&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 02:30:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103373#M162824</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-16T02:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: dax problem: subtract multiple values in same column based on DATE and filter and get final values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103395#M162825</link>
      <description>&lt;P&gt;sorry..result BI table can't be translated to English&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;does the table you want refer to all the data in rows 21-34 or rows 21, 22, 27, 28, 32.&amp;gt;&amp;gt; no, it's from all this table&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and I think this way is more clearly?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;result table is from A20:D33&amp;nbsp; and&amp;nbsp; A20:D33&amp;nbsp; is from&amp;nbsp;A1:D17 (raw data)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I can't find the solution to turn raw data to A20:D33..&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 02:52:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103395#M162825</guid>
      <dc:creator>iamjoy</dc:creator>
      <dc:date>2024-08-16T02:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: dax problem: subtract multiple values in same column based on DATE and filter and get final values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103455#M162828</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="791279" data-lia-user-login="iamjoy" class="lia-mention lia-mention-user"&gt;iamjoy&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Already have a preliminary understanding of what you need, but you didn't give any indication of how to determine the qty value corresponding to a type of instock_qty. For example, how to get the value 15735. One more thing, why the qty of A240600046 and A24070041 are marked in green, they have different order_no, which is different from the other calculation logic.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P style="text-align: justify; text-justify: inter-ideograph;"&gt;&lt;SPAN&gt;Best Regards,&lt;BR /&gt;Yang&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Community Support Team&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 03:19:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103455#M162828</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-16T03:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: dax problem: subtract multiple values in same column based on DATE and filter and get final values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103463#M162829</link>
      <description>&lt;P&gt;thank you for your reply&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;15735 is from C4+C8 (1922+13813, group by order_no and date, it's shipped on 6/19 )&lt;/P&gt;&lt;P&gt;and total instock qty group by order no , for example , A24040025 is&amp;nbsp; 22281 , and&amp;nbsp; all schedule ship qty is 30878+4122=35000&lt;/P&gt;&lt;P&gt;so 35000-22281=12719 (as final_unshipped_qty, and date need to use max schedule_ship_date, so it belongs to December)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;why the qty of A240600046 and A24070041 are marked in green, they have different order_no, which is different from the other calculation logic. &amp;gt;&amp;gt;&amp;gt;&amp;gt; It's all instocked in July (2182=213+1+1098+2+868), the result BI table will show instocked_qty and final_unshipped_qty by year/month&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Similarly,&amp;nbsp;we can get total instocked_qty in June is 15735, in May is 6546 (c23+c24+c25) and we don't have instocked_qty in Auguest.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 03:49:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4103463#M162829</guid>
      <dc:creator>iamjoy</dc:creator>
      <dc:date>2024-08-16T03:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: dax problem: subtract multiple values in same column based on DATE and filter and get final values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4106406#M162955</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="791279" data-lia-user-login="iamjoy" class="lia-mention lia-mention-user"&gt;iamjoy&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can try following dax to achieve your need.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;DAX:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;sumQTY By OrderNo and type = 
CALCULATE(
    SUM('Table'[QTY]),
    FILTER(
        'Table',
        'Table'[type] = EARLIER('Table'[type]) 
        &amp;amp;&amp;amp; 'Table'[order_no] = EARLIER('Table'[order_no])
        )
    )

Result 1 = 
VAR CurrentIndex = 'Table'[Index]
VAR NextIndex = CurrentIndex + 1
VAR CurrentOrderNo = 'Table'[order_no]
VAR CurrentDate = 'Table'[date]
VAR NextType =
    CALCULATE (
        MAX ( 'Table'[type] ),
        FILTER ( 'Table', 'Table'[Index] = NextIndex )
    )
VAR PreviousFinalUnshippedQty =
    CALCULATE (
        MAX ( 'Table'[sumQTY By OrderNo and type] ),
        FILTER ( 'Table', 'Table'[Index] = NextIndex )
    )
VAR _result1 = 
IF (
    COUNTROWS(
        FILTER(
            'Table',
            'Table'[order_no] = CurrentOrderNo &amp;amp;&amp;amp;
            'Table'[date] = CurrentDate
        )
    ) &amp;gt; 1,
    CALCULATE (
        DIVIDE(SUM('Table'[QTY]),COUNTROWS(
        FILTER(
            'Table',
            'Table'[order_no] = CurrentOrderNo &amp;amp;&amp;amp;
            'Table'[date] = CurrentDate
        )
    )),
        FILTER(
            'Table',
            'Table'[order_no] = CurrentOrderNo &amp;amp;&amp;amp;
            'Table'[date] = CurrentDate
        )
    ),
    BLANK()
)
VAR _result2 =
    IF (
        CurrentOrderNo
            = CALCULATE (
                MAX ( 'Table'[order_no] ),
                FILTER ( 'Table', 'Table'[Index] = NextIndex )
            )
            &amp;amp;&amp;amp; 'Table'[type] &amp;lt;&amp;gt; NextType,
        'Table'[sumQTY By OrderNo and type] - PreviousFinalUnshippedQty,
        _result1
    )

RETURN
    _result2


Result 2 = 
IF(
    'Table'[Result 1] = BLANK() ,
    'Table'[QTY]
)

final_unshipped_qty = 
VAR _qty = 'Table'[Result 2] + 'Table'[Result 1]
VAR _index = 'Table'[Index]
RETURN
IF(_index = 1,BLANK(),_qty)

New type = 
VAR _type = 
    SWITCH(
        'Table'[type],
        "schedule_ship_date","final_unshipped_qty",
        "instock_date","instock_qty"
    )
RETURN
IF(
    'Table'[final_unshipped_qty] &amp;lt;&amp;gt; 0,
    _type
)

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C01%7Cv-yaningyang%40microsoft.com%7Cce16d19809414d9f960208dbf1755128%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638369258411601530%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=oBisEpJnsk4p%2BcSV0F8sZ%2BFQHR%2FRvYA8sUWZIEcjQ4o%3D&amp;amp;reserved=0" target="_blank"&gt;How to get your questions answered quickly&lt;/A&gt;&amp;nbsp;--&amp;nbsp;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-provide-sample-data-in-the-Power-BI-Forum%2Fba-p%2F963216&amp;amp;data=05%7C01%7Cv-yaningyang%40microsoft.com%7Cce16d19809414d9f960208dbf1755128%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638369258411609718%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=sCaEt5xd5uTLXCby0%2B1XhR9V7RXxZLDCF088%2F9u%2FOUU%3D&amp;amp;reserved=0" target="_blank"&gt;&amp;nbsp;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 07:58:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-problem-subtract-multiple-values-in-same-column-based-on/m-p/4106406#M162955</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-19T07:58:56Z</dc:date>
    </item>
  </channel>
</rss>

