Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
We need insight in future stock levels on a weekly basic. Basic calculation is as follow:
Current stock level per article
plus
Planned receipts (purchase) up to week X minus 1
minus
Planned deliveries (sales) up to week X
= stock level in week X
We want this calculation for all articles for all current and future 13 weeks.
Database Stock
ItemId (article)
InStock
Modified (date)
Database GoodsReceipt_Lines (purchase)
ItemId (article)
QuantitityReceipts
Modified (date)
Database GoodsDelivery_lines (sales)
ItemId (article)
QuantitityDelivered
Modified (date)
The challenge for me is how to involve the week minus 1 in DAX.
Hopefuly somebody can push me in the right direction.
Solved! Go to Solution.
You want to calculate the stock level for each week for the next 13 weeks based on the current stock, planned receipts, and planned deliveries. The tricky part is involving the "week minus 1" in the calculation.
First, you'll need a calendar table that has all the weeks you're interested in. If you don't have one, you can create one in Power BI or use a DAX function like CALENDAR or CALENDARAUTO.
Now, let's create a measure for the stock level in week X.
Start by calculating the current stock level for each article:
CurrentStock = SUM(Database_Stock[InStock])
Next, calculate the planned receipts up to week X minus 1. This means you'll sum all the receipts up to the week before the current week in your calendar table:
PlannedReceipts =
CALCULATE(
SUM(Database_GoodsReceipt_Lines[QuantitityReceipts]),
FILTER(
Database_GoodsReceipt_Lines,
Database_GoodsReceipt_Lines[Modified] < MAX(Calendar[Date]) - 7
)
)
Here, I'm assuming your calendar table is named "Calendar" and has a column named "Date". The MAX(Calendar[Date]) - 7 part ensures you're looking at the week before the current week.
Then, calculate the planned deliveries up to week X:
PlannedDeliveries =
CALCULATE(
SUM(Database_GoodsDelivery_lines[QuantitityDelivered]),
FILTER(
Database_GoodsDelivery_lines,
Database_GoodsDelivery_lines[Modified] <= MAX(Calendar[Date])
)
)
Finally, combine these measures to get the stock level for week X:
StockLevelWeekX = CurrentStock + PlannedReceipts - PlannedDeliveries
Now, when you drag this measure into a table or matrix visual with weeks on the rows, you'll see the stock level for each week. Remember to filter your visual to the next 13 weeks to get the desired output.
You want to calculate the stock level for each week for the next 13 weeks based on the current stock, planned receipts, and planned deliveries. The tricky part is involving the "week minus 1" in the calculation.
First, you'll need a calendar table that has all the weeks you're interested in. If you don't have one, you can create one in Power BI or use a DAX function like CALENDAR or CALENDARAUTO.
Now, let's create a measure for the stock level in week X.
Start by calculating the current stock level for each article:
CurrentStock = SUM(Database_Stock[InStock])
Next, calculate the planned receipts up to week X minus 1. This means you'll sum all the receipts up to the week before the current week in your calendar table:
PlannedReceipts =
CALCULATE(
SUM(Database_GoodsReceipt_Lines[QuantitityReceipts]),
FILTER(
Database_GoodsReceipt_Lines,
Database_GoodsReceipt_Lines[Modified] < MAX(Calendar[Date]) - 7
)
)
Here, I'm assuming your calendar table is named "Calendar" and has a column named "Date". The MAX(Calendar[Date]) - 7 part ensures you're looking at the week before the current week.
Then, calculate the planned deliveries up to week X:
PlannedDeliveries =
CALCULATE(
SUM(Database_GoodsDelivery_lines[QuantitityDelivered]),
FILTER(
Database_GoodsDelivery_lines,
Database_GoodsDelivery_lines[Modified] <= MAX(Calendar[Date])
)
)
Finally, combine these measures to get the stock level for week X:
StockLevelWeekX = CurrentStock + PlannedReceipts - PlannedDeliveries
Now, when you drag this measure into a table or matrix visual with weeks on the rows, you'll see the stock level for each week. Remember to filter your visual to the next 13 weeks to get the desired output.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 9 | |
| 6 | |
| 5 |
| User | Count |
|---|---|
| 27 | |
| 22 | |
| 20 | |
| 17 | |
| 12 |