<?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: Stock planning with DAX in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Stock-planning-with-DAX/m-p/3434782#M130310</link>
    <description>&lt;P&gt;You want to calculate the stock level for each week for the next 13 weeks based on the current stock, planned receipts, and planned deliveries. The tricky part is involving the "week minus 1" in the calculation.&lt;/P&gt;
&lt;P&gt;First, you'll need a calendar table that has all the weeks you're interested in. If you don't have one, you can create one in Power BI or use a DAX function like CALENDAR or CALENDARAUTO.&lt;/P&gt;
&lt;P&gt;Now, let's create a measure for the stock level in week X.&lt;/P&gt;
&lt;P&gt;Start by calculating the current stock level for each article:&lt;/P&gt;
&lt;P&gt;CurrentStock = SUM(Database_Stock[InStock])&lt;BR /&gt;Next, calculate the planned receipts up to week X minus 1. This means you'll sum all the receipts up to the week before the current week in your calendar table:&lt;/P&gt;
&lt;P&gt;PlannedReceipts = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM(Database_GoodsReceipt_Lines[QuantitityReceipts]),&lt;BR /&gt;FILTER(&lt;BR /&gt;Database_GoodsReceipt_Lines,&lt;BR /&gt;Database_GoodsReceipt_Lines[Modified] &amp;lt; MAX(Calendar[Date]) - 7&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;Here, I'm assuming your calendar table is named "Calendar" and has a column named "Date". The MAX(Calendar[Date]) - 7 part ensures you're looking at the week before the current week.&lt;/P&gt;
&lt;P&gt;Then, calculate the planned deliveries up to week X:&lt;/P&gt;
&lt;P&gt;PlannedDeliveries = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM(Database_GoodsDelivery_lines[QuantitityDelivered]),&lt;BR /&gt;FILTER(&lt;BR /&gt;Database_GoodsDelivery_lines,&lt;BR /&gt;Database_GoodsDelivery_lines[Modified] &amp;lt;= MAX(Calendar[Date])&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;Finally, combine these measures to get the stock level for week X:&lt;/P&gt;
&lt;P&gt;StockLevelWeekX = CurrentStock + PlannedReceipts - PlannedDeliveries&lt;BR /&gt;Now, when you drag this measure into a table or matrix visual with weeks on the rows, you'll see the stock level for each week. Remember to filter your visual to the next 13 weeks to get the desired output.&lt;/P&gt;</description>
    <pubDate>Sun, 17 Sep 2023 17:54:36 GMT</pubDate>
    <dc:creator>technolog</dc:creator>
    <dc:date>2023-09-17T17:54:36Z</dc:date>
    <item>
      <title>Stock planning with DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Stock-planning-with-DAX/m-p/1089577#M15701</link>
      <description>&lt;P&gt;We need insight in future stock levels on a weekly basic. Basic calculation is as follow:&lt;/P&gt;&lt;P&gt;Current stock level per article&lt;/P&gt;&lt;P&gt;plus&lt;/P&gt;&lt;P&gt;Planned receipts (purchase) up to week X minus 1&lt;/P&gt;&lt;P&gt;minus&lt;/P&gt;&lt;P&gt;Planned deliveries (sales) up to week X&lt;/P&gt;&lt;P&gt;= stock level in week X&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We want this calculation for all articles for all current and future 13 weeks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Database Stock&lt;/P&gt;&lt;P&gt;ItemId (article)&lt;/P&gt;&lt;P&gt;InStock&lt;/P&gt;&lt;P&gt;Modified (date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Database GoodsReceipt_Lines (purchase)&lt;/P&gt;&lt;P&gt;ItemId (article)&lt;/P&gt;&lt;P&gt;QuantitityReceipts&lt;/P&gt;&lt;P&gt;Modified (date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Database GoodsDelivery_lines (sales)&lt;/P&gt;&lt;P&gt;ItemId (article)&lt;/P&gt;&lt;P&gt;QuantitityDelivered&lt;/P&gt;&lt;P&gt;Modified (date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The challenge for me is how to involve the week minus 1 in DAX.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefuly somebody can push me in the right direction.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2020 10:45:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Stock-planning-with-DAX/m-p/1089577#M15701</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-14T10:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Stock planning with DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Stock-planning-with-DAX/m-p/3434782#M130310</link>
      <description>&lt;P&gt;You want to calculate the stock level for each week for the next 13 weeks based on the current stock, planned receipts, and planned deliveries. The tricky part is involving the "week minus 1" in the calculation.&lt;/P&gt;
&lt;P&gt;First, you'll need a calendar table that has all the weeks you're interested in. If you don't have one, you can create one in Power BI or use a DAX function like CALENDAR or CALENDARAUTO.&lt;/P&gt;
&lt;P&gt;Now, let's create a measure for the stock level in week X.&lt;/P&gt;
&lt;P&gt;Start by calculating the current stock level for each article:&lt;/P&gt;
&lt;P&gt;CurrentStock = SUM(Database_Stock[InStock])&lt;BR /&gt;Next, calculate the planned receipts up to week X minus 1. This means you'll sum all the receipts up to the week before the current week in your calendar table:&lt;/P&gt;
&lt;P&gt;PlannedReceipts = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM(Database_GoodsReceipt_Lines[QuantitityReceipts]),&lt;BR /&gt;FILTER(&lt;BR /&gt;Database_GoodsReceipt_Lines,&lt;BR /&gt;Database_GoodsReceipt_Lines[Modified] &amp;lt; MAX(Calendar[Date]) - 7&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;Here, I'm assuming your calendar table is named "Calendar" and has a column named "Date". The MAX(Calendar[Date]) - 7 part ensures you're looking at the week before the current week.&lt;/P&gt;
&lt;P&gt;Then, calculate the planned deliveries up to week X:&lt;/P&gt;
&lt;P&gt;PlannedDeliveries = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM(Database_GoodsDelivery_lines[QuantitityDelivered]),&lt;BR /&gt;FILTER(&lt;BR /&gt;Database_GoodsDelivery_lines,&lt;BR /&gt;Database_GoodsDelivery_lines[Modified] &amp;lt;= MAX(Calendar[Date])&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;Finally, combine these measures to get the stock level for week X:&lt;/P&gt;
&lt;P&gt;StockLevelWeekX = CurrentStock + PlannedReceipts - PlannedDeliveries&lt;BR /&gt;Now, when you drag this measure into a table or matrix visual with weeks on the rows, you'll see the stock level for each week. Remember to filter your visual to the next 13 weeks to get the desired output.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Sep 2023 17:54:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Stock-planning-with-DAX/m-p/3434782#M130310</guid>
      <dc:creator>technolog</dc:creator>
      <dc:date>2023-09-17T17:54:36Z</dc:date>
    </item>
  </channel>
</rss>

