Forum Discussion

NaderSaeed's avatar
NaderSaeed
Helper II
4 years ago
Solved

Lag Column based on different loops and sorting

Hello,   Is there a way to get a Lagged Column for 'Table 1' [Value] (using a calculated column or a measure)  that returns the previous value of the column [Value]? After sorting by [Unit] then...
  • amitchandak's avatar
    4 years ago

    NaderSaeed , Try a new column like

     

    New column =
    var _max = maxx(filter(Table, [Unit] = earlier( [Unit]) && [Date] < earlier([Date]) && [Parameter] = earlier([Parameter]) ), [Date])
    return
    maxx(filter(Table, [Unit] = earlier( [Unit]) && [Date] =_max && [Parameter] = earlier([Parameter]) ), [Value])