Forum Discussion

alexricker0928's avatar
alexricker0928
Frequent Visitor
6 years ago
Solved

FIFO Quantity by Transfer Order

I have to calculate FIFO inventory quantities based on transfer order/itemid/date, only showing the transactions left after FIFO. The report will be run as of a specific date in the date filter, so t...
  • wdx223_Daniel's avatar
    6 years ago

    alexricker0928 you can try this code, it might help you.

    FIFO :=
    VAR _QTY =
        CALCULATE ( SUM ( Data[Transfer Qty] ) )
    VAR _CurrentDate =
        MAX ( Data[Date] )
    VAR _CurrentSO =
        MAX ( Data[Transfer/Sales Order #] )
    VAR _CurrentItem =
        VALUES ( Data[ItemId] )
    VAR _CurrentBalance =
        CALCULATE (
            SUM ( Data[Transfer Qty] ),
            FILTER (
                ALL ( Data ),
                Data[ItemId] IN _CurrentItem
                    && ( Data[Transfer/Sales Order #] <= _CurrentSO
                    && Data[Date] <= _CurrentDate
                    || Data[Transfer Qty] < 0 )
            )
        )
    RETURN
        IF ( _CurrentBalance > 0 && _QTY > 0, MIN ( _CurrentBalance, _QTY ) )