# @groups

```sql
-- @groups: Month, Product
```

## Valid Types

`List`

A comma separated list of columns to use as categories

## Full Example

```sql
-- @chart: bar
-- @title: Groups - Multiple category groups
-- @subtitle: An example of multiple category groups
-- @groups: Channel, Owner
-- @series: TotalSales
-- @formats: currency
SELECT 
	Final.*
FROM (  
  SELECT 
  	Channel,    
  	Owner,
    (
      SELECT sum(Sub.Amount)
      FROM Sales Sub
      WHERE Sub.Channel = Sales.Channel
    ) as TotalChannelSales,
    sum(Amount) as TotalSales
  FROM Sales
  WHERE Owner IN (
    SELECT Owner
    FROM Sales
    GROUP BY Owner
    ORDER BY sum(Amount)
    LIMIT 10
  )
  GROUP BY Channel, Owner
) as Final
ORDER BY TotalChannelSales ASC, TotalSales ASC

```

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2F2bSyHiMe1drgAdEDaSoF%2Fimage.png?alt=media&#x26;token=1547ffaa-c58f-4fb3-8e00-3c9929a1e952" alt=""><figcaption><p>An example bar chart grouped by a primary and secondary category</p></figcaption></figure>

| CHANNEL  | OWNER   | TOTALCHANNELSALES | TOTALSALES |
| -------- | ------- | ----------------- | ---------- |
| pr\_ad   | Kim     | 9181300.0         | 84603.0    |
| pr\_ad   | Roger   | 9181300.0         | 118985.0   |
| pr\_ad   | Lucy    | 9181300.0         | 138374.0   |
| pr\_ad   | Norbit  | 9181300.0         | 141711.0   |
| pr\_ad   | Justice | 9181300.0         | 160517.0   |
| pr\_ad   | Heather | 9181300.0         | 239870.0   |
| pr\_ad   | Peter   | 9181300.0         | 266655.0   |
| pr\_ad   | Tammy   | 9181300.0         | 501805.0   |
| coldcall | Justice | 1.7372264E7       | 87207.0    |
| coldcall | Heather | 1.7372264E7       | 162974.0   |
| coldcall | Norbit  | 1.7372264E7       | 333648.0   |
| coldcall | Tammy   | 1.7372264E7       | 335206.0   |
| coldcall | Roger   | 1.7372264E7       | 365129.0   |
| coldcall | Peter   | 1.7372264E7       | 725052.0   |
| search   | Lucy    | 3.3377707E7       | 139277.0   |
| search   | Kim     | 3.3377707E7       | 177605.0   |
| search   | Roger   | 3.3377707E7       | 223080.0   |
| search   | Grenda  | 3.3377707E7       | 333216.0   |

## Use Cases

Use groups to heirarchically group series columns together when you want to make visually distinct buckets. In the example above, without the @groups parameter, the chart would render without separating the parent category.

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2FhZGZzYqzdb1zk3Gjcahq%2Fimage.png?alt=media&#x26;token=aecd65cd-ea4f-4859-b205-ef1cc8bc0d13" alt=""><figcaption><p>An example of a recordset with two groups but not rendering the groups</p></figcaption></figure>
