KX Community

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

Home Forums kdb+ How can I apply a function with ‘if’ to a table? Re: How can I apply a function with ‘if’ to a table?

  • cillianreilly

    Member
    February 1, 2024 at 12:00 am

    You can also forgo any conditional statements in this case:

     

    q)update r:p1*p2*not p1=neg p2 from t1 
    TimeStamp stock p1 p2 r 
    ------------------------ 
    2018.01.01 AAPL 1 -1 0 
    2018.01.01 AAPL 2 1 2 
    2018.01.02 GOOGL -2 2 0 
    2018.01.02 GOOGL 3 0 0