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
nthomson
Frequent Visitor

Opening Stock Position Measure Calculation

Hello!
I am trying to create a measure that will show cumulative opening stock position in a matrix table but finding it challenging. 

 

The measure should sum the opening stock balance by taking the Opening stock  value from the previous month, then use values currently in 2 linked tables :

Add Purchase Order Qty 

Subtract Forecast Qty 

 

The starting value for the measure can be a measure 'Current month closing stock' which is a sum of current inventory, + Purchase Order Qty, - Forecast Qty for current month. 

 

 Nov-23Dec-23Jan-24Feb-24
Current stock500   
Forecast Sales - 100 - 100 - 100 - 100
Open Orders + 50 +50 + 50 + 50
     
Current month Closing stock450   
     
MEASURE: Opening Stock
= (Opening stock value from prev Month) + Open Orders - Forecast Sales
 450400350

 

Many thanks in advance

 

2 REPLIES 2
danextian
Super User
Super User

Hi @nthomson ,

 

Is that how your data is formatted - there's a separate column for each month? If so you need to unpivot your table first before doing any and create a date equivalent of your months (if they are a text string) before doing any calcuation. Your imported data should look like below:

danextian_0-1700965748257.png

And for your opening and closing stock measures:

Opening Stock = 
CALCULATE (
    SUM ( 'Table'[Values] ),
    FILTER (
        ALL ( 'Table'[Date], 'Table'[Period] ),
        'Table'[Date] < MAX ( 'Table'[Date] )
    )
)

Closing stock can be alternatively written as below since it is just cumulative sum of all inventory values.

Closing Stock = 
CALCULATE (
    SUM ( 'Table'[Values] ),
    FILTER (
        ALL ( 'Table'[Date], 'Table'[Period] ),
        'Table'[Date] <= MAX ( 'Table'[Date] )
    )
)

danextian_1-1700965860577.png

Please see attached pbix for your reference.

 

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

Hi,

I have solved similar problem in the 2 attached PBI files.  Please study them and apply those formulas to your dataset.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.