Forum Discussion

Mathewtmp's avatar
Mathewtmp
Frequent Visitor
1 year ago
Solved

Help to create a inventory projection report

Hi all,

Beginner here and trying to create a inventory projection report.

I have read a lot of related posts but have been unsuccessful in replicating the formulas. 

 

My database has a tables for stock on hand by SKU and Date for starting stock.

 

Stock in Transit for showing the stock scheduled to come in by date.

 

Demand shows the forecasted sales by date.

 

The final tables should effectively take the beginning stock on hand and deduct the weekly demand and add the stock in transit to show net Stock in that week. If there is not enough stock it should show the actual negative figure.

 

The model I have managed to put together as attached only shows the wekly figures and does not cumulatively add to the previous weeks net balance.

 

I would appreciate any help I can get to resolve this. Thanks in advance.

 

Link to Power Bi file;

https://www.dropbox.com/scl/fi/0dclld1wcux5i32eftlak/Dax-example.pbix?rlkey=luq8m3pbn6o1gtifyx7beitmm&st=v8ndn8ac&dl=0

 

Current Visual:

Expected visual:

 

  • Rupak_bi's avatar
    Rupak_bi
    1 year ago

    Hi Mathewtmp ,

    Here is your solution

    Steps to perform

    1. create an Union table as below

    Union table =
    ADDCOLUMNS(
        DISTINCT(
                UNION(
                    SELECTCOLUMNS(Demand,Demand[Date],Demand[Part No]),
                    SELECTCOLUMNS(SIT,SIT[Date],SIT[Part No]),
                    SELECTCOLUMNS(SOH,SOH[Date],SOH[Part No])
                )
        ),
        "Demand",LOOKUPVALUE(Demand[Demand],Demand[Date],Demand[Date],Demand[Part No],Demand[Part No]),
        "SOH",LOOKUPVALUE(SOH[Qty],SOH[Date],Demand[Date],SOH[Part No],Demand[Part No]),
        "SIT",LOOKUPVALUE(SIT[PO Qty],SIT[Date],Demand[Date],SIT[Part No],Demand[Part No])
    )
     
    2. Create a Measure
    Daily Balance =
     sum('Union table'[SOH])+sum('Union table'[SIT])-sum('Union table'[Demand])
    3. Create another measure
    Opening Balance =
    sum('Union table'[SOH])+
    CALCULATE([Daily Balance],ALLEXCEPT('Union table','Union table'[Demand_Part No]),'Union table'[Demand_Date]<max('Union table'[Demand_Date]))
    4. Create another Measure
    Stock Balance =
     CALCULATE([Daily Balance],ALLEXCEPT('Union table','Union table'[Demand_Part No]),'Union table'[Demand_Date]<=max('Union table'[Demand_Date]))
     
    Now take a matrix, columns as below

    Please note, all the columns will come from the new union table. 

    In your sample data, the incoming dates are coinsiding with demand dates. So I used demand date as axis which is simple. If it is not the case in your actual table, you need to use a date master. 

     

     

    thanks

    If this solves your issue, please accept as solution.

21 Replies

  • hello CampBI 

     

    What I can understand, your lines are breaking as you dont have consistent data in every week for reserve, SO and arrival and the graph representing correctly. connecting those lines will give a wrong representation. Rather I will suggest to use Matrix visual to represent this. Also in case of line graph, You may customize the chart like... connected line for forcasd and keep only dots for other categories. 
    If I missunderstood your ask, let me know some mote details of the concern

     

     

    thanks

    • CampBI's avatar
      CampBI
      Icon for Helper I rankHelper I

      Hi Rupak_bi ,

      See sample data below, The requirement should be cumulative or running total for forecast of inventory having the data for Daily qty, arrival, reserved and sales order.

       

      Sum of Inventory - Reserved + Arrival - Sales Order

       

      Seems I can't replicate the running total. Thank you.

       

      Item list table     
      ItemColorQtyInventory(today date only)  
      A12Black346/5/2025  
      A12Blue256/5/2025  
      A13Black66/5/2025  
            
            
      Purchase Order(Arrival Table)    
      ItemColorQtyarrival Date  
      A12Black1007/25/2025  
      A12Blue106/20/2025  
      A13Black166/30/2025  
            
      Sales Order Table     
      ItemColorQtyDate  
      A12Black36/11/2025  
      A12Blue476/22/2025  
      A13Black786/28/2025  
            
      Production (Reserved Table)    
      ItemColorQtyDate  
      A12Black26/5/2025  
      A12Blue36/22/2025  
      A13Black66/28/2025  
            
            
      Calendar Table(Date Table)    
      Calendar = CALENDAR (DATE (2024, 1, 1), DATE (2026, 12, 31))   
      • Rupak_bi's avatar
        Rupak_bi
        Icon for Super User rankSuper User

        Hi CampBI ,

        Thanks for sharing sample data. Can you plz share the image of expected visual for better understanding.

  • Hi CampBI ,

     

    Based on the sample data, the graph is looking like below. Let me know wheter I am in right track or you need something else

     

    • CampBI's avatar
      CampBI
      Icon for Helper I rankHelper I

      Hi Rupak_bi Yes! This is the right visualizatiob of the data, how it is come up with that? thank you so much. This is very helpful.

    • CampBI's avatar
      CampBI
      Icon for Helper I rankHelper I

      Hi Rupak_bi Yes that is the correct visualization in line chart, I tried again doing it like what you did but still no hope. I don't know why the other lines (Arrival, Reserved, and Sales Order) is continues and not only showing like static one line like yours. Thank you.

       

  •  Hi CampBI ,

     

    the process is same as I explained in the previous thread. 

    1. I have considered 4 source tables for Inventory, Productio, PO and SO. All these tables three columns name kept common. date, colour and item. values of these tables may have relevant column names.

    2. Created a union table:

    Union table = 
    ADDCOLUMNS(
        DISTINCT(
            union(
                DISTINCT(SELECTCOLUMNS(inventory,inventory[Date],inventory[Item],inventory[Color])),
                DISTINCT(SELECTCOLUMNS(PO,PO[Date],PO[Item],PO[Color])),
                DISTINCT(SELECTCOLUMNS(Production,Production[Date],Production[Item],Production[Color])),
                DISTINCT(SELECTCOLUMNS(SO,SO[Date],SO[Item],SO[Color]))
            )
        )
        
        ,
        "Inventory",LOOKUPVALUE(inventory[Inventory],inventory[Date],inventory[Date],inventory[Color],inventory[Color],inventory[Item],inventory[Item]),
        "PO",LOOKUPVALUE(PO[Arrival],PO[Date],inventory[Date],PO[Color],inventory[Color],PO[Item],inventory[Item]),
        "SO",LOOKUPVALUE(SO[Sale Order],SO[Date],inventory[Date],SO[Item],inventory[Item],SO[Color],inventory[Color]),
        "Prod",LOOKUPVALUE(Production[Production],Production[Date],inventory[Date],Production[Color],inventory[Color],Production[Item],inventory[Item])
        
    )

    3. Created a calculated column in the union table

    Stock = 'Union table'[Inventory]+'Union table'[PO]-'Union table'[Prod]-'Union table'[SO]

    4. Created a calender table and made relationship with all 4 source tables on date.. (note: dont make any relationship with the union table)

    5. Created a measure

    Stock forecast = 
    CALCULATE(sum('Union table'[Stock]),ALLEXCEPT('Union table','Union table'[inventory_Item],'Union table'[inventory_Color]),'Union table'[inventory_Date]<=max('Calendar'[Date]))

    6. now take a line & clustered bar chart combo visual. put date from the calender table in x-axis. put Stock forcast measure in the secondary axis. this will display the forcast.

    7. Now to create different bars for PO, SO ,Inventory and Production, create four different measure as below and put them in the primary Y-axis.

    Inventory_value = CALCULATE(sum('Union table'[Inventory]),'Union table'[inventory_Date]=max('Calendar'[Date]))
    SO_value = CALCULATE(sum('Union table'[SO]),'Union table'[inventory_Date]=max('Calendar'[Date]))
    Prod_Reserve_value = CALCULATE(sum('Union table'[Prod]),'Union table'[inventory_Date]=max('Calendar'[Date]))
    Arrival_value = CALCULATE(sum('Union table'[PO]),'Union table'[inventory_Date]=max('Calendar'[Date]))

     8. Slicers will be from union table.

     

    thats it. cheers....

     

    • CampBI's avatar
      CampBI
      Icon for Helper I rankHelper I

      Hi Rupak_bi I will try to replicate again the steps you have mentioned. Thank you so much. Could you please confirm if I connected it correctly? 

       

      • Rupak_bi's avatar
        Rupak_bi
        Icon for Super User rankSuper User

        dont make any connections. it will work without relations. with connection it may not work.

  • some of your date column is formatted as text. change it to date.

    • CampBI's avatar
      CampBI
      Icon for Helper I rankHelper I

      Thank you. And the Secondary Y-Axis is really can't change so it will be above the combo chart? above the bar graph? the value in secondary y-axis is per 10k and the other axis is 500 only that's why the Forecast is hitting some bar line and it is misleading when I see it. Is this really the case? or by design? Thank you.

       

      • Rupak_bi's avatar
        Rupak_bi
        Icon for Super User rankSuper User

        I am not able to understand your ask. See, in a combo chart, the axix range is set by default based on the minimum and maximum value for primary and secondary axis separately. If you want to see both in same scale, you need to make the axis range dynamic by creating two separate measure for minimum and maximum value and then refering them as Fx.

         

        If this solves your ask. Please accept as solution.

  • Mathewtmp's avatar
    Mathewtmp
    Frequent Visitor

    Hi Rupak,

     

    Thanks for replying. I am  assuming you meant the tables in the database?

    If so please see below the the same as text.

    Table SOH

    DatePart NoQty
    17/02/2025A111000
    17/02/2025O11500

     

    Table SIT

    DatePart NoPO Qty
    10/03/2025A11250
    14/04/2025A11250
    19/05/2025A11250
    24/02/2025O11125
    3/03/2025O11125
    7/04/2025O11125
    12/05/2025O11125
    9/06/2025O11125

     

    Table Demand

    DatePart NoDemand
    17/02/2025A11250
    24/02/2025A11250
    3/03/2025A11250
    10/03/2025A11250
    17/03/2025A11250
    24/03/2025A11250
    31/03/2025A11250
    7/04/2025A11250
    14/04/2025A11250
    21/04/2025A11250
    28/04/2025A11250
    5/05/2025A11250
    12/05/2025A11250
    19/05/2025A11250
    26/05/2025A11250
    2/06/2025A11250
    9/06/2025A11250
    17/02/2025O11125
    24/02/2025O11125
    3/03/2025O11125
    10/03/2025O11125
    17/03/2025O11125
    24/03/2025O11125
    31/03/2025O11125
    7/04/2025O11125
    14/04/2025O11125
    21/04/2025O11125
    28/04/2025O11125
    5/05/2025O11125
    12/05/2025O11125
    19/05/2025O11125
    26/05/2025O11125
    2/06/2025O11125
    9/06/2025O11125

     

    Table Part

    Part NoPart Name
    A11Apples
    O11Oranges

     

    • Rupak_bi's avatar
      Rupak_bi
      Icon for Super User rankSuper User

      Hi Mathewtmp ,

      Here is your solution

      Steps to perform

      1. create an Union table as below

      Union table =
      ADDCOLUMNS(
          DISTINCT(
                  UNION(
                      SELECTCOLUMNS(Demand,Demand[Date],Demand[Part No]),
                      SELECTCOLUMNS(SIT,SIT[Date],SIT[Part No]),
                      SELECTCOLUMNS(SOH,SOH[Date],SOH[Part No])
                  )
          ),
          "Demand",LOOKUPVALUE(Demand[Demand],Demand[Date],Demand[Date],Demand[Part No],Demand[Part No]),
          "SOH",LOOKUPVALUE(SOH[Qty],SOH[Date],Demand[Date],SOH[Part No],Demand[Part No]),
          "SIT",LOOKUPVALUE(SIT[PO Qty],SIT[Date],Demand[Date],SIT[Part No],Demand[Part No])
      )
       
      2. Create a Measure
      Daily Balance =
       sum('Union table'[SOH])+sum('Union table'[SIT])-sum('Union table'[Demand])
      3. Create another measure
      Opening Balance =
      sum('Union table'[SOH])+
      CALCULATE([Daily Balance],ALLEXCEPT('Union table','Union table'[Demand_Part No]),'Union table'[Demand_Date]<max('Union table'[Demand_Date]))
      4. Create another Measure
      Stock Balance =
       CALCULATE([Daily Balance],ALLEXCEPT('Union table','Union table'[Demand_Part No]),'Union table'[Demand_Date]<=max('Union table'[Demand_Date]))
       
      Now take a matrix, columns as below

      Please note, all the columns will come from the new union table. 

      In your sample data, the incoming dates are coinsiding with demand dates. So I used demand date as axis which is simple. If it is not the case in your actual table, you need to use a date master. 

       

       

      thanks

      If this solves your issue, please accept as solution.

      • Mathewtmp's avatar
        Mathewtmp
        Frequent Visitor

        Hi Rupak_bi ,

        Thank you so much for your help with the solution. It works perfectly. 🙂

        Much appreciated. 

        Cheers,

        Mat