<?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: Previous Week Inventory - this week Sales in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3877559#M151397</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="127675" data-lia-user-login="Volvo_Chang" class="lia-mention lia-mention-user"&gt;Volvo_Chang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since I don't know your data, I've created a sample table:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Then create new columns:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CurrentWeekInventory = 
CALCULATE(
    SUM('Table'[Inventory]),
    FILTER(
        'Table',
        'Table'[Week] = EARLIER('Table'[Week]) - 1
    )
) - 'Table'[Sales]
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;NextWeekInventoryPrediction = 
'Table'[CurrentWeekInventory] - 'Table'[NextWeekSalesBaseline]
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my preview:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A title="https://community.powerbi.com/t5/community-blog/how-to-get-your-question-answered-quickly/ba-p/38490" 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%7C02%7Cv-yohua%40microsoft.com%7Ce1106bfabecb4734a5cc08dc2305bc51%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638423754744679080%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&amp;amp;sdata=24%2BceC5sFd3n3%2FhFDYILWFcNjCwVClBD%2BPBsSLVfJGk%3D&amp;amp;reserved=0" target="_blank" rel="noopener nofollow noreferrer"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yongkang Hua&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2024 03:42:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-04-30T03:42:25Z</dc:date>
    <item>
      <title>Previous Week Inventory - this week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3877060#M151382</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I like to create a new dax column based on previous week inventory - this week sales and be able to predict for the future.&lt;/P&gt;&lt;P&gt;First, there is no inventory data value past the current week so it is blank for the inventory past the current week.&lt;/P&gt;&lt;P&gt;So the dax is trying to grab the previous week inventory - this week sales as the new inventory for this week invenotry and this week inventory - next week sales(average baseline) as next week inventory prediction.&lt;/P&gt;&lt;P&gt;My problem is whenever there is no inventory past the current week, the new dax column is not sum up week over week calulation but only negative sales since that is the only cells has value past the current week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 22:31:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3877060#M151382</guid>
      <dc:creator>Volvo_Chang</dc:creator>
      <dc:date>2024-04-29T22:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Previous Week Inventory - this week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3877519#M151396</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/window-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank"&gt;WINDOW function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;expected result measure: =
VAR _startdate =
    CALCULATE ( MIN ( data[week_end_date] ), REMOVEFILTERS () )
VAR _startinginventory =
    CALCULATE ( SUM ( data[inventory] ), data[week_end_date] = _startdate )
VAR _previousinventorycumulate =
    CALCULATE (
        SUM ( data[inventory] ),
        WINDOW (
            1,
            ABS,
            -1,
            REL,
            ALL ( data[week_end_date] ),
            ORDERBY ( data[week_end_date], ASC )
        )
    )
VAR _salescumulate =
    CALCULATE (
        SUM ( data[sales] ),
        WINDOW (
            2,
            ABS,
            0,
            REL,
            ALL ( data[week_end_date] ),
            ORDERBY ( data[week_end_date], ASC )
        )
    )
RETURN
    SWITCH (
        TRUE (),
        MAX ( data[week_end_date] ) = _startdate, _startinginventory,
        _previousinventorycumulate - _salescumulate
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 03:15:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3877519#M151396</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-04-30T03:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Previous Week Inventory - this week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3877559#M151397</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="127675" data-lia-user-login="Volvo_Chang" class="lia-mention lia-mention-user"&gt;Volvo_Chang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since I don't know your data, I've created a sample table:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Then create new columns:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CurrentWeekInventory = 
CALCULATE(
    SUM('Table'[Inventory]),
    FILTER(
        'Table',
        'Table'[Week] = EARLIER('Table'[Week]) - 1
    )
) - 'Table'[Sales]
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;NextWeekInventoryPrediction = 
'Table'[CurrentWeekInventory] - 'Table'[NextWeekSalesBaseline]
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my preview:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A title="https://community.powerbi.com/t5/community-blog/how-to-get-your-question-answered-quickly/ba-p/38490" 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%7C02%7Cv-yohua%40microsoft.com%7Ce1106bfabecb4734a5cc08dc2305bc51%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638423754744679080%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&amp;amp;sdata=24%2BceC5sFd3n3%2FhFDYILWFcNjCwVClBD%2BPBsSLVfJGk%3D&amp;amp;reserved=0" target="_blank" rel="noopener nofollow noreferrer"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yongkang Hua&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 03:42:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3877559#M151397</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-30T03:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Previous Week Inventory - this week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3880662#M151484</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/291628" target="_self"&gt;&lt;SPAN class=""&gt;Jihwan_Kim&lt;/SPAN&gt;&lt;/A&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks. I think we are getting close. Instead of the first date you have inventory, I want the start inventory is based on the week of today. I have week indexing for my date table so I like to pin the start inventory is max(week index) = week index(today()). And I don't have next week inventory that will be this week invnetory - this week sales( I know I say next week but this week will work as well).&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 21:37:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3880662#M151484</guid>
      <dc:creator>Volvo_Chang</dc:creator>
      <dc:date>2024-04-30T21:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Previous Week Inventory - this week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3880691#M151486</link>
      <description>&lt;P&gt;Below is a screenshot of my dataset. supplier inventory QOH row 53 =&amp;nbsp; supplier inventory QOH row 52 + forecasted prodcution row 53 - baseline row 53.&amp;nbsp;&lt;/P&gt;&lt;P&gt;supplier inventory QOH row 54 =&amp;nbsp; supplier inventory QOH row 53 + forecasted prodcution row 54- baseline row 54.&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 21:56:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3880691#M151486</guid>
      <dc:creator>Volvo_Chang</dc:creator>
      <dc:date>2024-04-30T21:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Previous Week Inventory - this week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3915066#M152417</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Just like to follow up on this one. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 20:43:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3915066#M152417</guid>
      <dc:creator>Volvo_Chang</dc:creator>
      <dc:date>2024-05-13T20:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Previous Week Inventory - this week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3915813#M152439</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you for your message, and please share your sample pbix file's link, and then I can try to look into it.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 03:31:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3915813#M152439</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-05-14T03:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Previous Week Inventory - this week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3917746#M152494</link>
      <description>&lt;P&gt;Hello Jihwan,&lt;/P&gt;&lt;P&gt;Thank you so much for reply.&lt;/P&gt;&lt;P&gt;Please see below with my dummy dataset and screenshot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I like to create a measure or dax to be able to take the most recent supplier invenotry QOH from row 11 + row 12 forecast production - row 12 baseline = row 12 supplier inventory. Row 13 supplier inventory qoh = row 12 supplier invneoty 923,607(from calculation above)+ 72000-17933. and the sequence continues to the alst row.&lt;img /&gt;&lt;A title="Dummy Dataset in Power BI Desktop" href="https://drive.google.com/file/d/1nSIRnbtyE_AwmjD9C2EBWanVzyuUD4Ot/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/1nSIRnbtyE_AwmjD9C2EBWanVzyuUD4Ot/view?usp=sharing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 15:08:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Week-Inventory-this-week-Sales/m-p/3917746#M152494</guid>
      <dc:creator>Volvo_Chang</dc:creator>
      <dc:date>2024-05-14T15:08:50Z</dc:date>
    </item>
  </channel>
</rss>

