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

    Hi,

    Is this the result you are looking for?

    q)select c2:(0^(prev(c2)+10) + c1)%2 from update c2:((0^prev(c1)+10) + c1)%2 from t 
    c2 
    ----- 
    0 
    6.25 
    9.75 
    10.75 
    11.75 
    12.75 
    13.75 
    14.75 
    15.75

    In this case, you need to explicitly fill in the zero as the result of prev on the first item of a list is null.

    Appendix A. Built-in Functions – Q for Mortals (kx.com)