Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

FEFO Violation

Hi, Trying to put a flag ("X") on Articles that were shipped violating FEFO (First Expiry First Out)   Logic: shipment violated FEFO if for the article, expiry date on shippment is earlier than ex...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  Anonymous ,

    Here are the steps you can follow:

    1. In Power query. Add Column – Index Column – From 1.

    2. Create calculated column.

    Violation Flag =
    var _current=CALCULATE(MAX('Table'[Expiry date]),FILTER(ALL('Table'),'Table'[Article]=EARLIER('Table'[Article])&&'Table'[Index]=EARLIER('Table'[Index])))
    var _Before=CALCULATE(MAX('Table'[Expiry date]),FILTER(ALL('Table'),'Table'[Article]=EARLIER('Table'[Article])&&'Table'[Index]=EARLIER('Table'[Index])-1))
    return
    IF(
        _current<_Before,"x",BLANK())

    3. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly