Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
PBI_1107
Frequent Visitor

Current Ending inventory Calculation followed by cumulative calculation for upcoming months

Hello Community,
I am having trouble finding the DAX Calculation for the Ending Inventory. The calculation goes like this 
1. Current_Ending_Inventory = (Inventory + Transit + Schedules) - ((Forecast * Reference number[)+ Future_orders + Backorders)
This calculation gives me the Ending Inventory for the current Month ( Oct 2023), 
I want a Calculation where for the following month will be like :
Nov 23 Ending Inventory= [Oct 23 Ending Inventory + Oct 23 Schedules] - [Oct 23 Forecast + Oct 23 Future_orders]

Similarly Dec 23 Ending Inventory = [Nov 23 Ending Inventory + Nov 23 Schedules] - [Nov 23 Forecast + Nov23 Future_orders]
So on and so forth.....
Here is the Table for your better understanding:
This table is Based on ID_NO and SHIP_MONTH

PBI_1107_0-1697142148646.png

 

3 REPLIES 3
PBI_1107
Frequent Visitor

Hello @Alef_Ricardo_ , 
I thank you for responding back to the post immediately, 
I have a question regarding the calcualtion you have given. So for "VAR PreviousEndingInv" The [EndingInventory] is it the CurrentEndingInventory or a different calculation, Becuase the values are showing different results.
Please let me know
thanks.

Alef_Ricardo_
Resolver II
Resolver II

To calculate the ending inventory for each month, you can create a DAX measure that accumulates the inventory changes over time. You'll need to use a combination of measures to calculate the ending inventory for each month based on the specified formula. Below is the DAX measure for your requirement:

```DAX
Ending Inventory =
VAR CurrentMonth = MAX('YourTable'[SHIP_MONTH])
VAR PreviousMonth = MAX('YourTable'[SHIP_MONTH]) - 1
VAR CurrentEndingInventory =
CALCULATE(
[Inventory] + [Transit] + [Schedules] - ([Forecast] * [Reference number] + [Future_orders] + [Backorders]),
'YourTable'[SHIP_MONTH] = CurrentMonth
)
VAR PreviousEndingInventory =
CALCULATE(
[Ending Inventory],
'YourTable'[SHIP_MONTH] = PreviousMonth
)
RETURN
IF(
CurrentMonth = MIN('YourTable'[SHIP_MONTH]),
CurrentEndingInventory,
PreviousEndingInventory + [Schedules] - ([Forecast] + [Future_orders])
)
```

Make sure to replace `'YourTable'` with the actual name of your table, and ensure that your table has the necessary columns: SHIP_MONTH, Inventory, Transit, Schedules, Forecast, Reference number, Future_orders, and Backorders.

This measure calculates the ending inventory for each month based on the formula you specified, taking into account the previous month's ending inventory. The IF statement checks if the current month is the minimum month in your table (i.e., the starting point), and if so, it uses the current month's ending inventory. Otherwise, it calculates the ending inventory based on the previous month's ending inventory, schedules, and the forecast and future orders for the current month.

Hello @Alef_Ricardo_ ,
I tired the calculation you gave and the value for the Oct month was correct but for the months after Oct 23 were showing different Values: 

PBI_1107_1-1697648422875.png

But this is How the Actual result should look like:

PBI_1107_0-1697648383819.png

The Calculation with the "PreviousEndingInv" in the Return function gives the accurate result for Oct 23 month but for Nov, dec and so on the visual is showing different values:
This is the calculation I used :
''' DAX

EndingInventory =
VAR CurrentMonth = MAX('New_Table'[SHIP_MONTH].[Date])
VAR PrevMonth = MAX('New_Table'[SHIP_MONTH].[Date])-1
VAR CurrentEndingInv =
([Inventory_Sum] + [Transit_sum] + [Schedules_Sum]) - (([FORECAST]*[Reference number])+[FDO_CPRO_sum] + [Backorders_sum1])
VAR CurrentEndingInv1 =
            CALCULATE(
            CurrentEndingInv , 'New_Table'[SHIP_MONTH] = CurrentMonth)
VAR PreviousEndingInv =
CALCULATE(CurrentEndingInv, 'New_Table'[SHIP_MONTH].[Date] = PrevMonth)
    Return PreviousEndingInv

''''
Please let me know if there is any changes i need to make.
Thanks,
PBI_1107

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Top Solution Authors