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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Woody
Regular Visitor

Calculating a stock depletion

Hi there,

 

I need your help for, at least in excel, a simple formula, but in PBI I'm going crazy thinking about a solution. I have a fixed stock of an item today, let's say 42. And now I have a forecast for the next 10 days, each day a different number.

 

Now I want the future stock of that item, subtracted by the needed value of that day which is the new base for the next row. My goal is, getting a matrix, where I can see, on which date the stock is going to be negative so we know we need to do a new order.

 

My base data looks like this:

Artikel_IDDate_of_Deliverynumber of itemstotal_stock
123405.05.2020510
123406.05.2020410
123407.05.2020310

The total stock is from right now.

 

What I need is a new column, which displays the subtraction until it's negative, something like this (last column), so I can create this matrix with the date as columns, the articles in the rows and the "difference" as the value part, so I have a forecast, based on our current stock of this article.

 

article_IDDate_of_Deliverynumber of itemstotal_stockDifference
123405.05.20205105
123406.05.20204101
123407.05.2020310-2

 

Goal:

article_ID05.05.202006.05.202007.05.202008.05.2020
123451-2-8
321525034105
4351230128-10

 

Greetings

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @Woody ,

 

Try this measure:

 

Difference =
SUM('Table'[total_stock]) - CALCULATE(SUM('Table'[number of items]); FILTER(ALL('Table'[Date_of_Delivery]); 'Table'[Date_of_Delivery] <= MAX('Table'[Date_of_Delivery])))
Capture.PNG
 
Ricardo
 


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

3 REPLIES 3
camargos88
Community Champion
Community Champion

Hi @Woody ,

 

Try this measure:

 

Difference =
SUM('Table'[total_stock]) - CALCULATE(SUM('Table'[number of items]); FILTER(ALL('Table'[Date_of_Delivery]); 'Table'[Date_of_Delivery] <= MAX('Table'[Date_of_Delivery])))
Capture.PNG
 
Ricardo
 


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



This works perfectly ... thank you so much

Woody
Greg_Deckler
Community Champion
Community Champion

Check out Days of Supply: https://community.powerbi.com/t5/Quick-Measures-Gallery/Days-of-Supply/m-p/635656#M318

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors