Forum Discussion
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;
Current Visual:
Expected visual:
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 MeasureDaily Balance =sum('Union table'[SOH])+sum('Union table'[SIT])-sum('Union table'[Demand])3. Create another measureOpening 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 MeasureStock 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 belowPlease 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
- Rupak_bi
Super User
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 concernthanks
- CampBI
Helper 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 Item Color Qty Inventory(today date only) A12 Black 34 6/5/2025 A12 Blue 25 6/5/2025 A13 Black 6 6/5/2025 Purchase Order(Arrival Table) Item Color Qty arrival Date A12 Black 100 7/25/2025 A12 Blue 10 6/20/2025 A13 Black 16 6/30/2025 Sales Order Table Item Color Qty Date A12 Black 3 6/11/2025 A12 Blue 47 6/22/2025 A13 Black 78 6/28/2025 Production (Reserved Table) Item Color Qty Date A12 Black 2 6/5/2025 A12 Blue 3 6/22/2025 A13 Black 6 6/28/2025 Calendar Table(Date Table) Calendar = CALENDAR (DATE (2024, 1, 1), DATE (2026, 12, 31))
- Rupak_bi
Super User
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....
- Rupak_bi
Super User
some of your date column is formatted as text. change it to date.
- CampBI
Helper 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
Super 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.
- Rupak_bi
Super User
- MathewtmpFrequent 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
Date Part No Qty 17/02/2025 A11 1000 17/02/2025 O11 500 Table SIT
Date Part No PO Qty 10/03/2025 A11 250 14/04/2025 A11 250 19/05/2025 A11 250 24/02/2025 O11 125 3/03/2025 O11 125 7/04/2025 O11 125 12/05/2025 O11 125 9/06/2025 O11 125 Table Demand
Date Part No Demand 17/02/2025 A11 250 24/02/2025 A11 250 3/03/2025 A11 250 10/03/2025 A11 250 17/03/2025 A11 250 24/03/2025 A11 250 31/03/2025 A11 250 7/04/2025 A11 250 14/04/2025 A11 250 21/04/2025 A11 250 28/04/2025 A11 250 5/05/2025 A11 250 12/05/2025 A11 250 19/05/2025 A11 250 26/05/2025 A11 250 2/06/2025 A11 250 9/06/2025 A11 250 17/02/2025 O11 125 24/02/2025 O11 125 3/03/2025 O11 125 10/03/2025 O11 125 17/03/2025 O11 125 24/03/2025 O11 125 31/03/2025 O11 125 7/04/2025 O11 125 14/04/2025 O11 125 21/04/2025 O11 125 28/04/2025 O11 125 5/05/2025 O11 125 12/05/2025 O11 125 19/05/2025 O11 125 26/05/2025 O11 125 2/06/2025 O11 125 9/06/2025 O11 125 Table Part
Part No Part Name A11 Apples O11 Oranges - Rupak_bi
Super 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 MeasureDaily Balance =sum('Union table'[SOH])+sum('Union table'[SIT])-sum('Union table'[Demand])3. Create another measureOpening 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 MeasureStock 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 belowPlease 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.