---
schema_version: "1"
id: 67f949660bc9e94bc4b267c91b1917ab3da8fdc2705715c65e81af43fd922f38
title: Group Interactions
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_bindings/guides/bi-dashboard-bindings-wave-designer-use-case-group.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-bindings/guide/bi-dashboard-bindings-wave-designer-use-case-group.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: c494397a51b1043d587aefe1aac900b4c9a8883304a7fdfcd16a720145704057
products:
  - Analytics Interactions
  - analytics
---
# Group Interactions

Bind the grouping to allow the dashboard viewer to select which dimensions to group the results by. For example, you can show different groupings in a chart based on the selection in a toggle widget.

To dynamically set the grouping in a query based on a selection, bind the `groups` property in the query. If the query is used for a chart, also bind the corresponding widget property under `columnMap` to identify the chart attribute by the selected grouping. Some charts accept multiple groupings and use them differently. For example, the stacked bar chart can have two groupings, one for the vertical axis and one used to segment the bars. The `columnMap` widget-level property has subproperties that specify which grouping to use for each of these chart attributes.

To dynamically set the grouping in a query based on a selection, complete these tasks.

- Bind the `groups` property of the query.
- If the query is used for a chart, replace the `columnMap` section of the widget with an empty `columns` array. Why? Because when you change the query, the set of fields can be different from what’s in the `columnMap` section. When you replace the `columnMap` property with an empty `columns` array, the system remaps the columns based on the new query definition.

For example, let’s bind the grouping for this donut chart based on the selection in the toggle widget.

![The toggle widgets allow you to choose a measure to display in the map chart.](https://developer.salesforce.com/docs/media/bi_dev_guide_bindings/bi_dashboard_grouping_binding_flex.png)

**note:** Dashboard selections automatically reset each time you change your query grouping. For example, if you drill into Air Up and then switch your grouping to Country, the donut chart resets and Air Up is no longer selected.

The toggle widget uses this custom query.

```json
"GroupingsController_1": {
    "type": "staticflex",
    "values": [
        {
            "display": "Country",
            "value": "Country"
        },
        {
            "display": "Product",
            "value": "Product"
        },
        {
            "display": "Rep Name",
            "value": "Referral"
        }
    ],
    "start": {
        "display": [ "Product" ]
    },
    "broadcastFacet": true,
    "groups": [],
    "label": "GroupingsController",
    "numbers": [],
    "selectMode": "singlerequired",
    "strings": []
}
```

Each toggle option has one display label (`display`) that appears in the toggle. It also has one value (`value`) that determines the grouping.

Let’s bind the `value` field of the custom query (`GroupingsController_1`) to the grouping in the donut chart’s query (`PieByProduct_2`). Any selection in the custom query passes the grouping to the `PieByProduct_2` query.

```json
"PieByProduct_2": {
    "label": "PieByProduct",
    "query": {
        "measures": [[
            "sum",
            "Amount"
        ]],
        "groups": [
            "{{ cell(GroupingsController_1.selection, 0, \\"value\\").asString() }}"
        ]
    },
    "broadcastFacet": true,
    "isGlobal": false,
    "receiveFacet": true,
    "selectMode": "single",
    "type": "aggregateflex",
    "useGlobal": true,
    "visualizationParameters": {
        "type": "chart",
        "parameters": {

            ...

        },
        "options": {}
    },
    "datasets": [
        {
            "id": "0FbB00000000q5gKAA",
            "label": "Flexy Sales",
            "name": "Flexy_Sales",
            "url": "/services/data/v42.0/wave/datasets/0FbB00000000q5gKAA"
        }
    ]
}
```

When you create the donut chart, by default, the widget (`chart_3`) contains the `columnMap` section that maps measures and groupings to chart attributes.

```json
"chart_3": {
    "type": "chart",
    "parameters": {
        "visualizationType": "pie",
        "step": "PieByProduct_2",
        "theme": "wave",
        "columnMap": {
            "trellis": [],
            "dimension": [
                "{{ cell(GroupingsController_1.selection, 0, \\"value\\").asString() }}"
            ],
            "plots": [ "sum_Amount" ]
        },

        ...

    }
}
```

**note:** The properties under the `columnMap` property vary based on the chart type.

For the interaction to work correctly, replace the `columnMap` section with an empty `columns` array.

```json
"chart_3": {
    "type": "chart",
    "parameters": {
        "visualizationType": "pie",
        "step": "PieByProduct_2",
        "theme": "wave",
        "columns" : [],

        ...

    }
}
```
