Home › Forums › kdb+ › Accumulators – Access additional list / column › Re: Accumulators – Access additional list / column
-
Thanks rocuinneagain,
Works for most scenarios. I have added one more row at the end where I get a different result than expected. The value for c2 in last row should be 4 instead of 3.
t:([]c: 30 40 25 20 4 4 1; c1: 10 20 5 25 5 4 3)
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 1 3 4 3>4(False) OR 4<4(False) ? 4 update c2:fills ?[(c1>prev c1) or 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 1 3 3