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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NewBIe2013
Regular Visitor

New opening inventory

Hi Bi folks, need your expertise here, I'm newbie to Power BI.

Would like to have a power bi dax to be able to achieve below result, it's relatively simple in Excel. 

The below shows a forecast of demand and projected stock to receipt, having the starting inventory (500) minus the demand (100) + stock receipt (1000 ) = 1400 (this is the next open inventory of next month). 

NewBIe2013_0-1701285687498.png

 

I had measures for all but just couldn't get to the new inventory (1400) for next month. 

 

Can you please help? Thanks.

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Jihwan_Kim_0-1701287974088.png

 

Opening inventory: =
VAR _initialinventory = 500
VAR _start =
    CALCULATE ( MIN ( Data[Date] ), ALL ( Data[Date] ) )
RETURN
    SWITCH (
        TRUE (),
        MAX ( Data[Date] ) = _start, _initialinventory,
        SUMX (
            WINDOW (
                1,
                ABS,
                -1,
                REL,
                SUMMARIZE ( ALL ( Data ), Data[Date], Data[Demand], Data[Stock receipt] ),
                ORDERBY ( Data[Date], ASC )
            ),
            Data[Stock receipt] - Data[Demand]
        ) + _initialinventory
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
NewBIe2013
Regular Visitor

@Jihwan_Kim thanks much, that's what I need. 

Fowmy
Super User
Super User

@NewBIe2013 

How does your source data look like? Sharing sample/dummy data would be helpful with the expected output. Save in Google Drive and share the link here granting permission to open.

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Jihwan_Kim_0-1701287974088.png

 

Opening inventory: =
VAR _initialinventory = 500
VAR _start =
    CALCULATE ( MIN ( Data[Date] ), ALL ( Data[Date] ) )
RETURN
    SWITCH (
        TRUE (),
        MAX ( Data[Date] ) = _start, _initialinventory,
        SUMX (
            WINDOW (
                1,
                ABS,
                -1,
                REL,
                SUMMARIZE ( ALL ( Data ), Data[Date], Data[Demand], Data[Stock receipt] ),
                ORDERBY ( Data[Date], ASC )
            ),
            Data[Stock receipt] - Data[Demand]
        ) + _initialinventory
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.