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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
tobisw
Regular Visitor

Run-out Date Calculation

EDIT: How can i add a PBIX Testfile to that message?
Hello,
i´m working on a run-out date calculation in which we would like to see, on which date the stock coverage for different part number goes for the first time below zero.
My approach was following:
  1. Create Date table and established relationship between date table & Purchase Coverage table
  2. Created Cumulative Stock Coverage Measure with following code:
Cumulative Stock Coverage =
CALCULATE(
[Stock Coverage Measure running],
FILTER(ALLSELECTED('Date'[Date]),
'Date'[Date]<= MAX('Date'[Date])))

 

 3. For the conditional colour format i created a add. measure Colour Coding stock Coverage with following code:

 

Colour_Coding_Stock_Coverage =
IF(
[Cumulative Stock Coverage]>= 0,"",1)
 
4. Target what i would like to achieve is, to get a add. value/measure, which tells me, from which date on, our stock went for the first time below 0 (zero).
 
For below screenshot, the value/measure should show 10.12.2021 as the first run-out date.
Who could give me a hint how to calculate this date?
Thanks in advance!
powerbi_screenshot.jpg
 
1 ACCEPTED SOLUTION

Here would be a simplistic version

 

First Run Out = CALCULATE(min('Table'[Attribute]),'Table'[Value]<0,'Table'[Measure]="Stock Coverage (EOB)")

 

Without the involvement of the dates table yet (although that is always a good thing to have). see attached.

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. 

Thanks for your hint. Please find below the relevant data for that topic - please note, that i entpivot the columns in the PowerQuery Editor.

Plant  (Local)Material (Global)  Calendar Day01.12.202102.12.202108.12.202109.12.202110.12.202115.12.202103.01.202205.01.202206.01.202212.01.202213.01.202219.01.202220.01.202226.01.202227.01.2022
M0/1815Purchase PartStock Coverage (EOB)PCE11.00011.0004.5004.500-3.500-9.000-9.000-14.500-14.500-19.500-19.500-24.500-24.500-29.000-29.000
M0/1815Purchase PartStockPCE11.000              
M0/1815Purchase PartRequirementsPCE  6.500 8.0005.500 5.500 5.000 5.000 4.500 
M0/1815Purchase PartSupplier OrdersPCE 7.500 7.500  1.000 5.000 5.000 4.500 5.000
M0/1815Purchase PartASN                

Here would be a simplistic version

 

First Run Out = CALCULATE(min('Table'[Attribute]),'Table'[Value]<0,'Table'[Measure]="Stock Coverage (EOB)")

 

Without the involvement of the dates table yet (although that is always a good thing to have). see attached.

Thanks a lot - is there a solution to create that date based on a measure too? 
Reason behind is, that in a 2nd step i would like to add the ASN quantities (these reflects parts in transit) to the calculation which would move the run out to a later date

Sorry should have specified that my sample code was for a measure.

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.