KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Accessing previous calculated value from a column in current row Re: Accessing previous calculated value from a column in current row

  • RVR

    Member
    January 4, 2022 at 12:00 am

    Hi,

    I have added the calculations below.

    c1 c2 Calculation
    1 5.5 =((0+10) + 1)/2 =((prev(c2)+10)+c1)/2
    2 8.75 =((5.5+10) + 2)/2
    3 10.875 =((8.75+10) + 3)/2
    4 12.4375 =((10.875+10) + 4)/2
    5 13.71875 =((12.4375+10) + 5)/2
    6 14.859375 =((13.71875+10) + 6)/2
    7 15.9296875 =((14.859375+10) + 7)/2
    8 16.96484375 =((15.9296875+10) + 8)/2

    c2 column values is the expected result.