Forum Discussion

Olwin's avatar
Olwin
Frequent Visitor
4 years ago

Inventory Beginning and Ending Balance

Hi there,

 

I want to create a measure that shows Beginning Balance and Ending Balance of my Inventory.

I have 2 tables: Master Item and Inventory Transaction.

Here are my sample data:

 

Master Item

Item No.
A
B
C

 

Inventory Transaction

DateItemAmount
1-Jan-2021A  1,200,000.00
1-Feb-2021A      (60,000.00)
1-Mar-2021B     300,000.00
1-Apr-2021B      (10,000.00)
1-May-2021C     500,000.00
1-Jun-2021A       20,000.00
1-Jul-2021B       30,000.00
1-Aug-2021C      (15,000.00)
1-Sep-2021A       24,000.00
1-Oct-2021B        (5,800.00)
1-Nov-2021B       30,000.00
1-Dec-2021C18,000.00

 

I also have slicer to filter my Date.

My expected output is like below table: (Date Filter = 01-Mar-2021 to 30-Nov-2021)

ItemBeg BalanceEnding Balance
A1,140,000.001,184,000.00
B0344,200.00
C0485,000.00

 

Kindly please advise, how can I achive this.

Thank you.

6 Replies

  • selimovd's avatar
    selimovd
    Icon for Most Valuable Professional rankMost Valuable Professional

    Hey Olwin ,

     

    that's possible with DAX measures:

    Beg. Balance =
    CALCULATE(
        SUM( 'Inventory Transaction'[Amount] ),
        'Inventory Transaction'[Date] = MIN( 'Inventory Transaction'[Date] )
    )
    

     

    And for the end balence:

    End Balance =
    CALCULATE(
        SUM( 'Inventory Transaction'[Amount] ),
        'Inventory Transaction'[Date] = MAX( 'Inventory Transaction'[Date] )
    )
    

     

    Be aware that you need a proper date table for the filtering to work. Here is a small tutorial how to create a date table:
     
    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution βœ”οΈ and give it a thumbs up πŸ‘
     
    Best regards
    Denis
     
    • selimovd's avatar
      selimovd
      Icon for Most Valuable Professional rankMost Valuable Professional

      Hey Olwin ,

       

      in this case you have to change the posting date to equal the exact minimum date, like this:

      BegBal =
      VAR first_date = [FirstDateVisible]
      RETURN
          CALCULATE(
              SUM( VE[Cost Amount] ),
              VE[Posting Date] = first_date
          )
      

       

      Also you have to make sure your the relationship between the Dates and the fact table has to be 1:n with single filter direction:

       

      Then it should work like you want.

       

      If you need any help please let me know.
      If I answered your question I would be happy if you could mark my post as a solution βœ”οΈ and give it a thumbs up πŸ‘
       
      Best regards
      Denis