KDB+ How to Check that All Columns Have the Same Sign?

  • A+
Category:Languages

I have a table with the following columns: date, name, cashType, t1, t2, t3. I want to add a column that returns a boolean if the t1, t2, and t3 columns are equal.

This works but I had to hardcode t1, t2 and t3. The columns names change depending on the date. I want to pass in a list of columns dateCols:-3#cols data into the below code.

update validateSign: {x=/} each flip signum (d2018_05_28; d2018_05_29; d2018_05_30) from data 

 


In this instance we can use data dateCols to call the column list within the query,

update validateSign:{x=/}each flip signum data dateCols from data 

However, I do not think this query will generate the desired results, an alternative would be

update validateSign:1=(count distinct@)each flip signum data dateCols from data 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: