Reputation: 2785
I have a table with the following column names: portfolio
, tradeType
, currency
, security
, tradeQuantity
, tradeMV
, totalTradeMV
, transferMV
, and adjustedMV
I want to reduce the tradeQuantity
, tradeMV
, totalTradeMV
, transferMV
columns by the adjustedMV
Here is an example query:
odTradesAdjusted:update tradeQuantity:tradeQuantity-0f^adjustedMV,tradeMV:tradeMV-0f^adjustedMV,totalTradeMV:totalTradeMV-0f^adjustedMV,transferMV:transferMV-0f^adjustedMV from odTradesAdjusted
However, I want to do this only if the adjustedMV
is less than the other columns. I could do a vector conditional using ?
for each of the columns, but is there a more elegant way of doing this rather than writing out the vector conditional 4 times?
Upvotes: 1
Views: 772
Reputation: 13657
You can use apply (@
) with a little bit of subtraction logic:
@[t;`tradeQuantity`tradeMV`totalTradeMV`transferMV;{x-y*0<x-y}[;t`adjustedMV]]
Edit - this can be simplified to
@[t;`tradeQuantity`tradeMV`totalTradeMV`transferMV;{x-y*y<x}[;t`adjustedMV]]
Upvotes: 3