---
schema_version: "1"
id: 9a730d67229f59dccbb95314f058fb45159db5c5c6a452bd40fe92125e2ac06e
title: Bind Parts of a Query
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-query-parts.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-bindings/guide/bi-dashboard-bindings-wave-designer-use-case-query-parts.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: d55a9a32b81ded19010c6fa14bdc9c100af6c9eb7c4ddf9ca78d2bc916fc8f9a
products:
  - Analytics Interactions
  - analytics
---
# Bind Parts of a Query

You can dynamically set parts of a query based on the selection or results of another query. For example, you can set the grouping in a query based on the grouping selected in a chart.

Before we discuss how to bind the different parts of the query, let’s look at a comprehensive example. This example illustrates the interactions for different parts of a query. The chart is bound based on selections for grouping, measure, filter, order, and limit. When you make a selection in one of the toggle widgets, the chart changes to show the results of the modified query.

![The dashboard shows toggle widgets that dynamically modify the chart's query based on selections of groupings, measures, filters, orders, and limits.](https://developer.salesforce.com/docs/media/bi_dev_guide_bindings/bi_dashboard_binding_query_parts_flex.png)

Here’s the JSON for the queries that power this dashboard. The `Account_BillingCount_1` query is the underlying query for the chart widget. This query contains multiple interactions based on other queries.

```json
"steps": {
    "Account_BillingCount_1": {
        "datasets": [
            {
                "id": "0FbB00000000oEkKAI",
                "label": "Opportunities",
                "name": "opportunity",
                "url": "/services/data/v38.0/wave/datasets/0FbB00000000oEkKAI"
            }
        ],
        "isFacet": true,
        "isGlobal": false,
        "query": {
            "measures": "{{column(StaticMeasureNames.selection, [\\"value\\"]).asObject()}}",
            "limit": "{{column(StaticLimits.selection, [\\"value\\"]).asObject()}}",
            "groups": "{{column(StaticGroupingNames.selection, [\\"value\\"]).asObject()}}",
            "filters": "{{column(StaticFilters.selection, [\\"value\\"]).asObject()}}",
            "order": "{{column(StaticOrdering.selection, [\\"value\\"]).asObject()}}"
        },
        "selectMode": "single",
        "type": "aggregateflex",
        "useGlobal": true,
        "visualizationParameters": {
            "visualizationType": "hbar",
            "options": {}
        }
    },
    "StaticGroupingNames": {
        "datasets": [],
        "dimensions": [],
        "isFacet": true,
        "isGlobal": false,
        "selectMode": "single",
        "start": {
            "display": [
                "Country"
            ]
        },
        "type": "staticflex",
        "useGlobal": true,
        "values": [
            {
                "display": "Country",
                "value": "Account.BillingCountry"
            },
            {
                "display": "Industry",
                "value": "Account.Industry"
            },
            {
                "display": "Product",
                "value": "Product.Product.Family"
            },
            {
                "display": "Source",
                "value": "Account.AccountSource"
            }
        ],
        "visualizationParameters": {
            "options": {}
        }
    },
    "StaticFilters": {
        "datasets": [],
        "dimensions": [],
        "isFacet": true,
        "isGlobal": false,
        "selectMode": "single",
        "start": {
            "display": "Ads Only"
        },
        "type": "staticflex",
        "useGlobal": true,
        "values": [
            {
                "display": "Ads Only",
                "value": [
                    "LeadSource",
                    [
                        "Advertisement"
                    ],
                    "in"
                ]
            },
            {
                "display": "Partners Only",
                "value": [
                    "Account.Type",
                    [
                        "Partner"
                    ],
                    "in"
                ]
            },
            {
                "display": "$1M+ Only",
                "value": [
                    "Amount",
                    [
                        [
                            1000000,
                            11921896
                        ]
                    ],
                    ">=<="
                ]
            }
        ],
        "visualizationParameters": {
            "options": {}
        }
    },
    "StaticOrdering": {
        "datasets": [],
        "dimensions": [],
        "isFacet": true,
        "isGlobal": false,
        "selectMode": "single",
        "start": {
            "display": "Ads Only"
        },
        "type": "staticflex",
        "useGlobal": true,
        "values": [
            {
                "display": "Ascending",
                "value": [
                    -1,
                    {
                        "ascending": true
                    }
                ]
            },
            {
                "display": "Descending",
                "value": [
                    -1,
                    {
                        "ascending": false
                    }
                ]
            }
        ],
        "visualizationParameters": {
            "options": {}
        }
    },
    "StaticLimits": {
        "datasets": [],
        "dimensions": [],
        "isFacet": true,
        "isGlobal": false,
        "selectMode": "single",
        "start": {
            "display": [
                "5"
            ]
        },
        "type": "staticflex",
        "useGlobal": true,
        "values": [
            {
                "display": "5",
                "value": 5
            },
            {
                "display": "10",
                "value": 10
            },
            {
                "display": "25",
                "value": 25
            }
        ],
        "visualizationParameters": {
            "options": {}
        }
    },
    "StaticMeasureNames": {
        "datasets": [],
        "dimensions": [],
        "isFacet": true,
        "isGlobal": false,
        "selectMode": "singlerequired",
        "start": {
            "display": [
                "Total Amount"
            ]
        },
        "type": "staticflex",
        "useGlobal": true,
        "values": [
            {
                "display": "Max Employees",
                "value": [
                    "max",
                    "Account.NumberOfEmployees"
                ]
            },
            {
                "display": "Total Amount",
                "value": [
                    "sum",
                    "Amount"
                ]
            },
            {
                "display": "Avg Amount",
                "value": [
                    "avg",
                    "Amount"
                ]
            }
        ],
        "visualizationParameters": {
            "options": {}
        }
    },
    "Account_AccountSourc_1": {
        "datasets": [
            {
                "id": "0FbB00000000oEkKAI",
                "label": "Opportunities",
                "name": "opportunity",
                "url": "/services/data/v38.0/wave/datasets/0FbB00000000oEkKAI"
            }
        ],
        "isFacet": true,
        "isGlobal": false,
        "query": {
            "measures": [
                [
                    "count",
                    "*"
                ]
            ],
            "groups": [
                "Account.AccountSource"
            ],
            "order": [
                [
                    -1,
                    {
                        "ascending": false
                    }
                ]
            ]
        },
        "type": "aggregateflex",
        "useGlobal": true,
        "visualizationParameters": {
            "visualizationType": "hbar",
            "options": {}
        }
    }
},
"widgetStyle": {
    "backgroundColor": "#FFFFFF",
    "borderColor": "#E6ECF2",
    "borderEdges": [],
    "borderRadius": 0,
    "borderWidth": 1
}
```

**note:** If you bind a measure or grouping in a query used for a chart, you must also replace the `columnMap` section in the widget-level chart JSON with an empty `columns` array. For more information, see [Measure Interactions](https://developer.salesforce.com/docs/analytics/bi-dev-guide-bindings/guide/bi-dashboard-bindings-wave-designer-use-case-measure.md) and [Group Interactions](https://developer.salesforce.com/docs/analytics/bi-dev-guide-bindings/guide/bi-dashboard-bindings-wave-designer-use-case-group.md).
