<?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: Calculate stock in hand from initial date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4345099#M172544</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="715724" data-lia-user-login="User_790790" class="lia-mention lia-mention-user"&gt;User_790790&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;In case you want to achieve this result as measure instead of calculated column.&lt;BR /&gt;Below are the code&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EOD SIH = 30
//It emans Sep's Stock in Hand&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;StockInhand = 
VAR _QtyIssueRT = 
CALCULATE(
    SUM( 'Table'[Quantity Issued] ),
    FILTER( ALL( 'Table'[Date] ),
    'Table'[Date] &amp;lt;= MAX( 'Table'[Date] )
    ) )
VAR _QtySoldRT = 
CALCULATE(
    SUM( 'Table'[Qty Sold] ),
    FILTER( ALL( 'Table'[Date] ),
    'Table'[Date] &amp;lt;= MAX( 'Table'[Date] )
    ) )
VAR _Result = 
[EOD SIH] + _QtyIssueRT - _QtySoldRT
RETURN
_Result&lt;/LI-CODE&gt;&lt;P&gt;Below screenshot&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Let me know if you need help for end of the mnth stock in hand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;sanalytics&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 28 Dec 2024 10:01:20 GMT</pubDate>
    <dc:creator>sanalytics</dc:creator>
    <dc:date>2024-12-28T10:01:20Z</dc:date>
    <item>
      <title>Calculate stock in hand from initial date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4344804#M172536</link>
      <description>&lt;P&gt;I have the following table below :-&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The remaining stock in hand from the end of the month (30th sep) is 30.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to calculate stock in hand like this&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;01-10-2024 Stock in hand = Stock in hand end of month + Quantity Issued on 1st - QTY Sold&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = 30 + 5 - 2&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = 33&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Then the remaining stock from the previous day to be added with qty issued like the below&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;02-10-2024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t;TD&gt;3&lt;/TD&gt;&lt;TD&gt;53&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12-10-24&lt;/TD&gt;&lt;TD&gt;TV&lt;/TD&gt;&lt;TD&gt;John&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;49&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 27 Dec 2024 17:05:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4344804#M172536</guid>
      <dc:creator>User_790790</dc:creator>
      <dc:date>2024-12-27T17:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate stock in hand from initial date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4345008#M172543</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Dec 2024 05:42:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4345008#M172543</guid>
      <dc:creator>ThxAlot</dc:creator>
      <dc:date>2024-12-28T05:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate stock in hand from initial date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4345099#M172544</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="715724" data-lia-user-login="User_790790" class="lia-mention lia-mention-user"&gt;User_790790&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;In case you want to achieve this result as measure instead of calculated column.&lt;BR /&gt;Below are the code&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EOD SIH = 30
//It emans Sep's Stock in Hand&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;StockInhand = 
VAR _QtyIssueRT = 
CALCULATE(
    SUM( 'Table'[Quantity Issued] ),
    FILTER( ALL( 'Table'[Date] ),
    'Table'[Date] &amp;lt;= MAX( 'Table'[Date] )
    ) )
VAR _QtySoldRT = 
CALCULATE(
    SUM( 'Table'[Qty Sold] ),
    FILTER( ALL( 'Table'[Date] ),
    'Table'[Date] &amp;lt;= MAX( 'Table'[Date] )
    ) )
VAR _Result = 
[EOD SIH] + _QtyIssueRT - _QtySoldRT
RETURN
_Result&lt;/LI-CODE&gt;&lt;P&gt;Below screenshot&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Let me know if you need help for end of the mnth stock in hand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;sanalytics&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Dec 2024 10:01:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4345099#M172544</guid>
      <dc:creator>sanalytics</dc:creator>
      <dc:date>2024-12-28T10:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate stock in hand from initial date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4345266#M172550</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="715724" data-lia-user-login="User_790790" class="lia-mention lia-mention-user"&gt;User_790790&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Do you need a calculated column or a measure?&lt;BR /&gt;If it is a measure please be more precise about the model (tables and relationships available) and the existing context in the report. actually that measure correspond to a running total with the measure&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;stock= SUM ('Table'[Quantity Issued]) - SUM ('Table'[Qty Sold])&lt;/LI-CODE&gt;&lt;P&gt;if all the columns are placed in the same "Table" then this measure could work:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure Stock in hand=
CALCULATE (
    SUM ( 'Table'[Quantity Issued] ) - SUM ( 'Table'[Qty Sold] ),
    FILTER ( ALL('Table'), 'Table'[Date] &amp;lt;= MAX('Table'[Date] ) )
)
​&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;if you need a calculated column please use this CalcColumn Dax formula:&amp;nbsp;&lt;BR /&gt;--&amp;gt; changing the "table" with your actual table name.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;Column =
CALCULATE (
    SUM ( 'Table'[Quantity Issued] ) - SUM ( 'Table'[Qty Sold] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Date] &amp;lt;= EARLIER ( 'Table'[Date] ) )
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;I hope this helps, if so please accept as a solution. Kudos are welcome&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Dec 2024 20:08:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4345266#M172550</guid>
      <dc:creator>pcoley</dc:creator>
      <dc:date>2024-12-28T20:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate stock in hand from initial date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4359216#M173058</link>
      <description>&lt;P&gt;Thanks, i'll check it out. Sorry for the lack of clarity. I have three tables one is stock in hand from prev month, quantity issued, sales data. I would like to get the result in a new table if it's possible.&lt;BR /&gt;&lt;BR /&gt;&lt;A title="Link" href="https://docs.google.com/spreadsheets/d/1mqJBUTHIwDU380uukvLYloHRgZsnS6Mz/edit?usp=sharing&amp;amp;ouid=104076749508283104516&amp;amp;rtpof=true&amp;amp;sd=true" target="_self"&gt;https://docs.google.com/spreadsheets/d/1mqJBUTHIwDU380uukvLYloHRgZsnS6Mz/edit?usp=sharing&amp;amp;ouid=104076749508283104516&amp;amp;rtpof=true&amp;amp;sd=true&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2025 17:48:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-stock-in-hand-from-initial-date/m-p/4359216#M173058</guid>
      <dc:creator>User_790790</dc:creator>
      <dc:date>2025-01-10T17:48:59Z</dc:date>
    </item>
  </channel>
</rss>

