+ Reply to Thread
Results 1 to 6 of 6

Power Pivot/Query: Cumulative inventory based on future sales

  1. #1
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Power Pivot/Query: Cumulative inventory based on future sales

    Hi all!

    This request is specifically for Power Query/Power Pivot.

    I have two tables, one for inventory and one for sales.
    The inventory table shows current inventory by warehouse and SKU.
    The sales table shows sales that will be shipped in the future by SKU, warehouse, qty, ship date, and order #.

    The goal is to build a pivot table that shows the following:

    ROWS
    Order #
    SKU

    COLUMNS
    Ship date

    VALUES
    Current inventory
    Qty on order
    Net inventory (inventory after subtracting the qty on order and all orders with an earlier date)

    I have attached a simplified version of my data as well as what the desired outcome would be.
    Attached Files Attached Files

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Power Pivot/Query: Cumulative inventory based on future sales

    Hi,

    Currently your Inventory table is neither used in the Pivot Table nor added to the Data Model, so I'm not sure why you mention that.

    Also, in your file you state "this would show 33 (55-2-24)", though I believe your arithmetic is wrong there!

    Try this measure:

    PHP Code: 
    Net Inventory :=
    SUMSales[Available] )
        - 
    CALCULATE(
            
    SUMSales[Qty] ),
            
    FILTER(
                
    ALLEXCEPTSalesSales[SKU] ),
                
    Sales[Order #]
                    
    IN "O1""O2" }
                        && 
    Sales[Ship Date] <= MINSales[Ship Date] )
            )
        ) 
    though you need to clarify what the results should be for O3.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Power Pivot/Query: Cumulative inventory based on future sales

    Please try

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Power Pivot/Query: Cumulative inventory based on future sales

    XOR LX, the inventory table is used to bring the inventory into the sales table.
    I am not sure if this is the best way to go about this but this is what I have done.
    You are right, my arithmetic was incorrect in the file. That should have been 29 not 33.
    I can't hardcode O1, O2, O3, etc. since there are so many and it will be changing.
    In this example, O1 and O2 pull from the same warehouse (as shown in the sales table) and O3 does not so the inventory depends on what warehouse the SKU is being pulled from.

    Bo_Ry, this is exactly what I am looking for, however I was not able to successfully implement it into my file.
    I made a more representative sample of my actual data and have attached it here.
    Once I see that this is working as is, I will be inserting "Your Ref. (Sold-To)" in the pivot between sales rep and SKU, but I did not include that in this sample to keep it cleaner (and I don't think that will change anything).

    I want to be able to collapse the pivot table and have the inventory for the different SKUs add up correctly without duplicating.

    To illustrate the issue, I filtered the pivot by a single SKU.

    Your help is greatly appreciated as always!
    Attached Files Attached Files
    Last edited by 63falcondude; 06-17-2022 at 04:42 PM.

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Power Pivot/Query: Cumulative inventory based on future sales

    Sorry, I'm not able to find the Data model context logic to make
    Rep3 with only WC to include qty from Rep1 with WA, WC

    You need to create Calendar table to make total running work on date

    PHP Code: 
    =
    VAR 
    =
        
    MAX 'Calendar'[Date] )
    RETURN
        IF (
            
    SUM Orders[Qty] ),
            
    MAX Orders[Inventory] )
                - 
    CALCULATE (
                    
    SUM Orders[Qty] ),
                    
    ALL Orders[Sales RepName] ),
                    
    Orders[Warehouse]
                        
    IN CALCULATETABLE VALUES Orders[Warehouse] ), ALL 'Calendar'[Month] ) ),
                    
    'Calendar'[Date] <= D
                
    )
        ) 
    Attached Files Attached Files

  6. #6
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Power Pivot/Query: Cumulative inventory based on future sales

    Bo_Ry, you are absolutely right. This was an oversight on my part.
    Rep 3 orders from that SKU should only subtract from WC, so that 13 that you marked as red was correct.

    This worked perfectly. I seriously cannot thank you enough!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Power Query/Power Pivot Conditional Column creation & chart
    By mz_h in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-12-2020, 06:07 PM
  2. [SOLVED] 2 fields checker- Request for alternative option in Power Query or Power Pivot
    By Shareez Saleem in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-15-2020, 08:36 AM
  3. [SOLVED] Power Query to find last sales date
    By josephteh in forum Excel General
    Replies: 9
    Last Post: 10-17-2020, 06:26 AM
  4. [SOLVED] Power Query - cumulative per month, but in one row
    By afgi in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 02-21-2020, 04:19 AM
  5. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM
  6. FIFO Sales Valuation - Using Power Query
    By Jonny757 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-26-2018, 06:32 PM
  7. I want to use Power Query to keep track of Inventory
    By 83Rob83 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2018, 03:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1