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

  • vkennedy

    Member
    January 4, 2022 at 12:00 am
    Hello,
    To modify the table in place, pass it by name (i.e. `t).
    q)t:([]c1: 1 2 3 4 5 6 7 8 9) 
    q)update c2:((prev(c1)+10) + c1)%2 from `t `t 
    q)update c2:((prev(c2)+10) + c1)%2 from `t `t 
    q)t 
    c1 c2 
    -------- 
    1 2 
    3 9.75 
    4 10.75 
    5 11.75 
    6 12.75 
    7 13.75 
    8 14.75 
    9 15.75