# combining groupBy in tickscript

**URL:** <https://community.influxdata.com/t/combining-groupby-in-tickscript/13214>\
**Category:** Systems\
**Tags:** kapacitor\
**Created:** [February 27, 2020, 7:50am UTC](https://community.influxdata.com/t/combining-groupby-in-tickscript/13214 "2020-02-27T07:50:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ninad\_Sheth](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ninad_sheth/32/4480_2.png) [@Ninad\_Sheth](https://community.influxdata.com/u/Ninad_Sheth)\
**Post date:** [February 27, 2020, 7:50am UTC](https://community.influxdata.com/t/combining-groupby-in-tickscript/13214/1 "2020-02-27T07:50:15Z")

</div>

Hi,

I have a script like following

```auto
batch 
   |query('SELECT sum("value") FROM "app"."autogen"."measurement" WHERE ' + 
       'product = \'' + product + '\'')
       .every(1m)
       .offset(5m)
       .period(1m)
       .groupBy('event_type')
       .align()
       .fill('none')
   |alert()
       .warn(lambda: 0 < 1)
       .message(message + ' {{.Group}}')
       .idTag(idTag)
       .levelTag(levelTag)
       .messageField(messageField)
       .durationField(durationField)
       .log('/var/lib/kapacitor/logs/alerts.log')

```

It calls `alert` node for every unique `event_type` as given in documentation. But I want to combine it somehow. for me `event_type` has types like 404, 400, 401, total\_request etc (these are variable) and i want to find percentage of 404, 400, 401 and then say  
`if percentage(404) > x and percentage(400) < y and percentage(401) > 0` then push something to influxdb different measure. (percentage(x) = sum(x)/total\_requests\*100)

And in order to do this i need to have access to all those `sum('value')` of all event\_types in the same node at same time so that can use it in my usecase. One way i found was to get all data without groupBy and then find different sums on kapacitor side. but it ends up retrieving 100k+ values which is waste.

So what would be other way of doing it ?

Thanks !
