Functional select with fby, grouping on multiple columns

Hi KDB gurus,

I’ve figured out that the functional form of this query: 

select from rows where 1=(count;i) fby (sym;market;id;price;size;eventType)

is this:

?[rows;enlist(=;1;(fby;(enlist;#:;`i);(+:;(!;enlist`sym`market`id`price`size`eventType;(enlist;`sym;`market;`id;`price;`size;`eventType)))));0b;()]

My question is how can I run the functional select if the grouped columns are passed in/stored in a variable? I have  symmarketidpricesizeeventType passed into a function and stored in a variable gCols , but am having trouble trying to correctly place that in the functional select in the fby section. Thanks

try something like this (assuming rows is available in scope)

{[gCols] ?[rows;enlist(=;1;(fby;(enlist;count;i);(flip;(!;enlist gCols;(enlist,gCols)))));0b;()]}[symmarketidpricesizeeventType]`