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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX Formula: Inventory QOH in reverse

Disclaimer: I just started working with DAX and I've read and watched a ton of content but I'm still getting hung up on very simple problems.  I learn faster if I can see the solutions to the problems in my head.

 

I have an inventory table which holds all item specifics: Quantity on Hand, PAR, Location, etc.

I also have a transaction table that shows all of the (+/-) transactions that happened to any given item.

 

Instead of simply calculating a units in stock like:

 

UnitsInStockSimple =
CALCULATE (
    SUM ( 'Transaction Data'[Qty] ),
    FILTER (
        ALL ( 'Date Table'[Date] ),
        'Date Table'[Date] <= MAX( 'Date Table'[Date] )
    )
)

 

I want to work in reverse and pick up the QOH field from the Inventory table and work backwards through the dates.  The final result should be the QOH on for any given date:

 

Example for item 123

Current QOH is 400

Yesterday (during 1 day) there were 3 transactions in desc order: -3 (distribution), -1 (Adjustment), +6 (order receipt)

I would like to see the QOH for each date: 403, 404, 398

 

Because: If the last transaction subtracted 3 and today's QOH is 400, then the QOH before the transaction must have been 403.

15 REPLIES 15

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.