Forum Discussion

Rigoleto's avatar
Rigoleto
Helper II
8 years ago
Solved

get value from Previous row

Need a funtion or logic to read a previous row, for instance:                     How can you see Do I need is to sum up the previos record and build a new column with those values Ap...
  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    8 years ago

    Rigoleto

     

    I think this calculated column would work.

    See the attached sample file as well

     

    Calculated Column =
    VAR PreviousRow =
        TOPN (
            1,
            FILTER (
                Table1,
                Table1[Month] < EARLIER ( Table1[Month] )
                    && Table1[Employee] = EARLIER ( Table1[Employee] )
            ),
            [Month], DESC
        )
    VAR PreviousValue =
        MINX ( PreviousRow, [Sales] )
    RETURN
        Table1[Sales] + PreviousValue