<?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: Calculating Inventory value for the stocks on hand on any selected date including historic values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Inventory-value-for-the-stocks-on-hand-on-any/m-p/2516804#M70019</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as I know [Time Stamp] column is a datetime format column and show in date type. I suggest you to create a date only&amp;nbsp; [Time Stamp] column first.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Time Stamp (Only Date) = DATEVALUE(StockAuditSample[Time Stamp])&lt;/LI-CODE&gt;
&lt;P&gt;Then I suggest you to create a measure to filter your visual.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
VAR _Highest_Timestamp = CALCULATE(MAX(StockAuditSample[Time Stamp (Only Date)]),FILTER(ALL(StockAuditSample),CALCULATE(SUM(StockAuditSample[New Qty On Hand]))&amp;lt;&amp;gt;0&amp;amp;&amp;amp; StockAuditSample[Time Stamp (Only Date)]&amp;lt;=SELECTEDVALUE('Date'[Date])))
VAR _new_oty_oh = CALCULATE(SUM(StockAuditSample[New Qty On Hand]))
RETURN
IF( MAX(StockAuditSample[Time Stamp (Only Date)]) =_Highest_Timestamp,IF(_new_oty_oh&amp;lt;&amp;gt;0,1,0))&lt;/LI-CODE&gt;
&lt;P&gt;Add this measure into visual level filter and then set it to show items when value = 1.&lt;/P&gt;
&lt;P&gt;Select 2021/12/22:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Select 2022/02/20:&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;</description>
    <pubDate>Mon, 16 May 2022 08:04:12 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-05-16T08:04:12Z</dc:date>
    <item>
      <title>Calculating Inventory value for the stocks on hand on any selected date including historic values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Inventory-value-for-the-stocks-on-hand-on-any/m-p/2513855#M69805</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying to create a measure in DAX to calculate the inventory value for the items currently in stock and also historically based on the date selected by the user.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the pbix file with sample data and a simplified data model of StockAudit table and a date dimension linked to it In my data I have:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;New Part number &amp;amp; New SL (Key combination)&lt;/LI&gt;&lt;LI&gt;Time Stamp (Date of the stock activity)&lt;/LI&gt;&lt;LI&gt;New Unit Cost (Price)&lt;/LI&gt;&lt;LI&gt;Old Qty On hand&lt;/LI&gt;&lt;LI&gt;New Qty On hand ( if its 0 out of stock, if its 1 or more then in stock)&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;There are some other columns and dimensions but the above should provide all detail required.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Expected result:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Now I need to write a DAX statement for calculating the inventory value (Price) for the items currently in stock for any given date:&lt;BR /&gt;(Example of my sample data)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;If the date is selected as 22.12.2021 the result set is the sum of new unit cost (53.500) with highest timestamp (in this case 20.12.2021) for three stocklines (144,145,150) with the condition new_oty_oh=1 three rows should be retrived&lt;img /&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&amp;nbsp; If the date is selected as 20.02.2022 the result set is the sum of new unit cost(35.000) with highest timestamp (in this case 18.02.2022) for only two stocklines (144,145) since 150 is out of stock with new_qty=0, onyl two rows should be retrived.&lt;BR /&gt;(There are repetitive records for some stocks because of different transactions to the stock on same day)&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;What Measures or Calculated columns would I need to achieve this output since the expectation is to check through each and every record for a New Part number &amp;amp; New SL combination to find the inventory value efficiently.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Link to the pbix file with data :&amp;nbsp;&lt;U&gt;&lt;A href="https://1drv.ms/u/s!AvA391_m0W9IpDsf36b_96OIineq?e=yxuboq" target="_blank"&gt;https://1drv.ms/u/s!AvA391_m0W9IpDsf36b_96OIineq?e=yxuboq&lt;/A&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking forward to the response, Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 15:34:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Inventory-value-for-the-stocks-on-hand-on-any/m-p/2513855#M69805</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-13T15:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Inventory value for the stocks on hand on any selected date including historic values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Inventory-value-for-the-stocks-on-hand-on-any/m-p/2516804#M70019</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as I know [Time Stamp] column is a datetime format column and show in date type. I suggest you to create a date only&amp;nbsp; [Time Stamp] column first.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Time Stamp (Only Date) = DATEVALUE(StockAuditSample[Time Stamp])&lt;/LI-CODE&gt;
&lt;P&gt;Then I suggest you to create a measure to filter your visual.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
VAR _Highest_Timestamp = CALCULATE(MAX(StockAuditSample[Time Stamp (Only Date)]),FILTER(ALL(StockAuditSample),CALCULATE(SUM(StockAuditSample[New Qty On Hand]))&amp;lt;&amp;gt;0&amp;amp;&amp;amp; StockAuditSample[Time Stamp (Only Date)]&amp;lt;=SELECTEDVALUE('Date'[Date])))
VAR _new_oty_oh = CALCULATE(SUM(StockAuditSample[New Qty On Hand]))
RETURN
IF( MAX(StockAuditSample[Time Stamp (Only Date)]) =_Highest_Timestamp,IF(_new_oty_oh&amp;lt;&amp;gt;0,1,0))&lt;/LI-CODE&gt;
&lt;P&gt;Add this measure into visual level filter and then set it to show items when value = 1.&lt;/P&gt;
&lt;P&gt;Select 2021/12/22:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Select 2022/02/20:&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;</description>
      <pubDate>Mon, 16 May 2022 08:04:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Inventory-value-for-the-stocks-on-hand-on-any/m-p/2516804#M70019</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-16T08:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Inventory value for the stocks on hand on any selected date including historic values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Inventory-value-for-the-stocks-on-hand-on-any/m-p/2536482#M71297</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;Thanks for the response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My requirement is not completly fulfilled though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a below example where I need total Inventory cost for the max of timestamp:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;In this case when I select today's date 24th May 2022 for this part number and stock line I need the final row with inventory cost as 28,617,43, i get last row for max timestamp but the unit cost is sum of all lines.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Please find my DAX as of below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Cost value = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'&lt;/SPAN&gt;&lt;SPAN&gt;,(&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'[New Qty On Hand]&lt;/SPAN&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'[New Unit Cost]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Inventory value latest = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;selecteddate&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;'Date'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;temptableA&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;SUMMARIZE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ALLSELECTED&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'[Time Stamp]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;=&lt;/SPAN&gt;&lt;SPAN&gt;selecteddate&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'[Time Stamp]&lt;/SPAN&gt;&lt;SPAN&gt;)=&lt;/SPAN&gt;&lt;SPAN&gt;StockAuditSample&lt;/SPAN&gt;&lt;SPAN&gt;[Max timestamp]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'[PK_Index]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"Cost"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'&lt;/SPAN&gt;&lt;SPAN&gt;[Cost value]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'&lt;/SPAN&gt;&lt;SPAN&gt;[Cost value]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;temptableA&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;LOOKUPVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'[PK_Index]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'StockAuditSample'[PK_Index]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;[PK_Index]&lt;/SPAN&gt;&lt;SPAN&gt;)))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please suggest where I'm wrong in this to get just the unit cost of the particular record, thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 13:53:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-Inventory-value-for-the-stocks-on-hand-on-any/m-p/2536482#M71297</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-24T13:53:29Z</dc:date>
    </item>
  </channel>
</rss>

