Forum Discussion

rajasekar_o's avatar
rajasekar_o
Helper V
2 years ago

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

 

 

 

3 Replies

  • 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.

     

     

     

     

    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:]

     

      • Jihwan_Kim's avatar
        Jihwan_Kim
        Super User

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

        thanks.