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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
RobRayborn
Helper IV
Helper IV

Identifying Stock On Hand

I am attempting to put together a data table that will provide me with the Stock On Hand that was on hand at any date I choose.
I have two SQL Data inputs. The first one provides me with the Stock On Hand right now.
The second SQL data is transactional, with columns: Part_ID, Date_Time_Created, and Quantity. 
Using the Stock On Hand right now and the transactions provided by the second table, how can I reduce and add the incoming Programing_ID stock transactions (Positive and negative transacitons) to determine how many of the Part_ID I had on hand?Data Transactions.png

1 ACCEPTED SOLUTION
Zanqueta
Super User
Super User

Hi .To calculate Stock On Hand for any past date, calculate stock backwards from the current Stock On Hand. Use a DAX measure that subtracts all transactions occurring after the selected date. This method requires no pre‑calculated historical tables and works directly with your current stock table and transaction table.

 

You need:
  • A table with the current Stock On Hand per Part_ID
  • A transaction table with Part_ID, Date_Time_Created, and Quantity
    You should also include a proper Date table for filtering.
     

    Stock On Hand At Date :=
    VAR SelectedDate =
        MAX ( 'Date'[Date] )

     

    VAR CurrentStock =
        CALCULATE (
            SUM ( StockNow[Stock_On_Hand] )
        )

     

    VAR TransactionsAfterDate =
        CALCULATE (
            SUM ( Transactions[Quantity] ),
            Transactions[Date_Time_Created] > SelectedDate
        )

     

    RETURN
        CurrentStock - TransactionsAfterDate

     

    This approach performs well and allows you to analyse inventory levels across any point in time using standard Power BI slicers.

     

     

     

@RobRayborn

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn

View solution in original post

3 REPLIES 3
v-priyankata
Community Support
Community Support

Hi @RobRayborn 

Thank you for reaching out to the Microsoft Fabric Forum Community.

@Zanqueta Thanks for the inouts.

I hope the information provided by user was helpful. If you still have questions, please don't hesitate to reach out to the community.

 

Hi @RobRayborn 

Hope everything’s going smoothly on your end. I wanted to check if the issue got sorted. if you have any other issues please reach community.

Zanqueta
Super User
Super User

Hi .To calculate Stock On Hand for any past date, calculate stock backwards from the current Stock On Hand. Use a DAX measure that subtracts all transactions occurring after the selected date. This method requires no pre‑calculated historical tables and works directly with your current stock table and transaction table.

 

You need:
  • A table with the current Stock On Hand per Part_ID
  • A transaction table with Part_ID, Date_Time_Created, and Quantity
    You should also include a proper Date table for filtering.
     

    Stock On Hand At Date :=
    VAR SelectedDate =
        MAX ( 'Date'[Date] )

     

    VAR CurrentStock =
        CALCULATE (
            SUM ( StockNow[Stock_On_Hand] )
        )

     

    VAR TransactionsAfterDate =
        CALCULATE (
            SUM ( Transactions[Quantity] ),
            Transactions[Date_Time_Created] > SelectedDate
        )

     

    RETURN
        CurrentStock - TransactionsAfterDate

     

    This approach performs well and allows you to analyse inventory levels across any point in time using standard Power BI slicers.

     

     

     

@RobRayborn

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn

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.