Forum Discussion

francoisl's avatar
francoisl
Helper II
2 years ago
Solved

Get Info from Previous Row (Again)

It seems I cannot get my head around this.  I looked at most posts on the same subject but I cannot create the proper column.    Here's a sample data  (table name = invtrx) warehouse       item  ...
  • Greg_Deckler's avatar
    2 years ago

    francoisl Assuming you want a calculated column and assuming you have an index, you could do this as a new calculated column:

     

    Calculated Column =
      VAR __Flag = [flag]
      VAR __Warehouse = [warehouse]
      VAR __Item = [item]
      VAR __Date = [date]
      VAR __Index = [index]
      VAR __Result = 
        IF( 
          __Flag <> BLANK(), 
          __Flag,
            VAR __Previous = MAXX( FILTER( 'Table', [warehouse] = __Warehouse && [item] = __Item && [date] < __Date && [flag] <> BLANK() ), [index])
            VAR __Result = MAXX( FILTER( 'Table', [index] = __Previous), [flag] )
          RETURN
            __Result
        )
    RETURN
      __Result