Functional select with fby, grouping on multiple columns

Hi KDB Gurus,

I have the functional form of this query:

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

as:

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

I have my symbol list of columns I want to group on,  symmarketidpricesizeeventType, stored in a local variable gCols. I am not sure how to run the functional form using my local variable. Help is much appreciated. Thanks.

Hey 

I know this is an old question, but I guess no harm in having an answer. 
I needed to do this recently and I found myself searching for something online. 

Here’s the magic that you need: 

assuming I have a variable: .ns.cols:symmarketidpricesizeeventType; {[x;y] ?[x;enlist(=;1;(fby;(enlist;#:;`i);(+:; (!;enlist y; (enlist;enlist,y)))));0b;()] }[rows;.ns.cols]