KX Community

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

Home Forums kdb+ Accumulators – Access additional list / column Re: Accumulators – Access additional list / column

  • RVR

    Member
    September 6, 2022 at 12:00 am

    Somehow not being able to use the previous calculated value of c2 directly is causing fallout for different combination of data. Last value of c2 will be 4 as per the logic but we get 3.5

    t:([]c: 30 40 25 20 4 4 4.5 4.5; c1: 10 20 5 25 5 4 3 3.5)

     

    c c1 c2 c1>prev c2 OR prev c < prev c2 ? c1 prev c2
    30 10 10 10>0 (True) OR No need of evaluation ? 10
    40 20 20 20>10(True) OR No need of evaluation ? 20
    25 5 20 5>20(False) OR 40<20(False) ? 20
    20 25 25 25>20(True) OR No need of evaluation ? 25
    4 5 5 5>25(False) OR 20<25(True) ? 5
    4 4 4 4>5(False) OR 4<5(True) ? 4
    4.5 3 4 3>4(False) OR 4<4(False) ? 4
    4.5 3.5 4 3.5>4(False) OR 4.5<4(False) ? 4

     

    update c2:fills ?[(c1>prev c1) or prev[c]<prev c1;c1;0N] from t 
    c c1 c2 
    ----------- 
    30 10 10 
    40 20 20 
    25 5  20 
    20 25 25
    4  5  5 
    4  4  4 
    4.5 3 4 
    4.5 3.5 3.5