Forum Discussion

PowerBITestingG's avatar
PowerBITestingG
Resolver I
3 years ago
Solved

Inventory DAX First in First out

So I basically want to compute a formula that calculates the Current Quantity -   Delivered quantity of the MAX(Delivered date) and then do it again for the next one until the Current Quantity gets depleted like in the table below

 

Item IDCurrent QuantityDelivered DateDelivered QuantityFormula
1054516/08/202250
1054524/08/2022230
1054501/09/2022610
1054511/10/20222121-23=-2
1054524/10/20222445-24=21

 

Any ideas? thank you!

  • Hi PowerBITestingG , try this calculate column: Name of column:"Table_"

    Formula = var cumulative=CALCULATE(SUM(Table_[Delivered Quantity]),
    FILTER(ALLEXCEPT(Table_,Table_[Item ID]),
    Table_[Delivered Date] >= EARLIER ( Table_[Delivered Date] )))
    return
    if(Table_[Current Quantity]-cumulative<0,0,
    Table_[Current Quantity]-cumulative
    )

    Best regards

1 Reply

  • Hi PowerBITestingG , try this calculate column: Name of column:"Table_"

    Formula = var cumulative=CALCULATE(SUM(Table_[Delivered Quantity]),
    FILTER(ALLEXCEPT(Table_,Table_[Item ID]),
    Table_[Delivered Date] >= EARLIER ( Table_[Delivered Date] )))
    return
    if(Table_[Current Quantity]-cumulative<0,0,
    Table_[Current Quantity]-cumulative
    )

    Best regards