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

View all the Fabric Data Days sessions on demand. View schedule

Reply
rajasekar_o
Helper V
Helper V

opening quantity closing quantity calculation

hi team,
need help for  calculating inventory opening quantity and closing quantity

 

with out date beet ween date selection opening quantity and closing quantity correctly showing
if i select any beetween date its not show correct opening quantity and closing quantity
i select date from 02-04-2022 to 14-02-2024 the actual opening quantity 1000 and closing quantity 1000
but its show opening quantity 333 and closing quantity 333, how to calculate opening quantity closing quantity

rajasekar_o_1-1707969053048.png

 

rajasekar_o_2-1707969053042.png

 

 

3 REPLIES 3
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.

 

Jihwan_Kim_1-1707972720049.png

 

 

Jihwan_Kim_0-1707972706185.png

 

In quantity: = 
SUM( Data[In qty] )

 

Out quantity: = 
SUM( Data[Out qty] )

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Opening quantity: = 
CALCULATE (
    [In quantity:] - [Out quantity:],
    WINDOW (
        1,
        ABS,
        -1,
        REL,
        ALL ( 'Calendar'[Date] ),
        ORDERBY ( 'Calendar'[Date], ASC )
    )
)

 

Closing quantity: = 
[Opening quantity:] + [In quantity:] - [Out quantity:]

 


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.

its not showing correct quantity

rajasekar_o_1-1707978863556.png

 

please share your sample pbix file, and then I can try to look into it.

thanks.


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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors