Search code examples
kdb

KDB - Mutiplying a col by -1 if different col = certain value


I have a set of data whereby there is a column which can take the value of "BUYS" or "SELLs" and I have another column where the quantity is displayed (shown in absolute terms). I want to be able to query this data and make sure that when the value = "SELLS" I am multiplying the quantity by -1.

thanks


Solution

  • You could try using a vector conditional?

    https://code.kx.com/q4m3/10_Execution_Control/#1013-vector-conditional-evaluation