---
schema_version: "1"
id: bc34f6afdd69d4e09ee4f28e5d3426439365d49d213da342ceb104314e187e1f
title: Measure and Group Bindings in Compact-Form and SAQL-Form Queries
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-compactform-saqlform.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-bindings/guide/bi-dashboard-bindings-wave-designer-use-case-compactform-saqlform.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 345cb4b68f402aeb71f0a5da67c3c4333c24912b8f038af972e54ec4c0ceadf3
products:
  - Analytics Interactions
  - analytics
---
# Measure and Group Bindings in Compact-Form and SAQL-Form Queries

You can use bindings in compact-form queries and SAQL-form queries.

Let's look at an example where the selections in two custom queries (`StaticSAQLMeasureNames` and `StaticSAQLGroupingNames`) determine the measure and grouping of a SAQL-form query. Notice that the bindings for both measures and groups are defined in two places. To learn more about strings, numbers, and groups fields, see [SAQL Step Type Properties](https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_json.meta/bi_dev_guide_json/bi_dbjson_steps_types_saql.htm).

```json
{
    "label": "New dashboard",
    "mobileDisabled": false,
    "state": {
        "steps": {
            "lens_1": {
                "type": "saql",
                "query": "q = load \"OpportunityWithAccount\";\nq = group q by {{column(StaticSAQLGroupingNames.selection, [\"value\"]).asGrouping()}};\nq = foreach q generate {{row(StaticSAQLGroupingNames.selection, [], [\"expression\", \"alias\"]).asProjection()}}, {{row(StaticSAQLMeasureNames.selection, [], [\"expression\", \"alias\"]).asProjection()}};\nq = order q by ‘AccountId.Industry’ asc;\nq = limit q 2000;",
                "useGlobal": true,
                "numbers": "{{column(StaticSAQLMeasureNames.selection, [\"alias\"]).asObject()}}",
                "groups": "{{column(StaticSAQLGroupingNames.selection, [\"alias\"]).asObject()}}",
                "strings": "{{column(StaticSAQLGroupingNames.selection, [\"alias\"]).asObject()}}",
                "visualizationParameters": {},
                "selectMode": "single",
                "broadcastFacet": true,
                "receiveFacetSource": {
                    "mode": "all",
                    "steps": []
                }
            },
            "StaticSAQLMeasureNames": {
                "datasets": [],
                "dimensions": [],
                "isFacet": true,
                "isGlobal": false,
                "selectMode": "singlerequired",
                "start": {
                    "display": [
                        "Total Amount"
                    ]
                },
                "type": "staticflex",
                "useGlobal": true,
                "values": [
                    {
                        "display": "Total Amount",
                        "cf": [
                            "sum",
                            "Amount"
                        ],
                        "expression": "sum(‘Amount’)",
                        "alias": "sum_Amount"
                    },
                    {
                        "display": "Avg Amount",
                        "cf": [
                            "avg",
                            "Amount"
                        ],
                        "expression": "avg(‘Amount’)",
                        "alias": "avg_Amount"
                    }
                ],
                "numbers": [],
                "strings": [],
                "groups": [],
                "columns": {},
                "broadcastFacet": true
            },
            "StaticSAQLGroupingNames": {
                "datasets": [],
                "dimensions": [],
                "isFacet": true,
                "isGlobal": false,
                "selectMode": "multirequired",
                "start": {
                    "display": [
                        "Country"
                    ]
                },
                "type": "staticflex",
                "useGlobal": true,
                "values": [
                    {
                        "display": "Industry",
                        "value": "AccountId.Industry",
                        "expression": "‘AccountId.Industry’",
                        "alias": "AccountId.Industry"
                    },
                    {
                        "display": "Source",
                        "value": "AccountId.AccountSource",
                        "expression": "‘AccountId.AccountSource’",
                        "alias": "AccountId.AccountSource"
                    }
                ],
                "numbers": [],
                "strings": [],
                "groups": [],
                "columns": {},
                "broadcastFacet": true
            }
        },
        "widgets": {
            "pillbox_3": {
                "type": "pillbox",
                "parameters": {
                    "compact": false,
                    "showActionMenu": true,
                    "exploreLink": false,
                    "fontSize": 14,
                    "textColor": "#0070D2",
                    "selectedTab": {
                        "textColor": "#FFFFFF",
                        "backgroundColor": "#0070D2",
                        "borderEdges": [
                            "all"
                        ],
                        "borderColor": "#C6D3E1",
                        "borderWidth": 1
                    },
                    "step": "StaticSAQLGroupingNames"
                }
            },
            "pillbox_4": {
                "type": "pillbox",
                "parameters": {
                    "compact": false,
                    "showActionMenu": true,
                    "exploreLink": false,
                    "fontSize": 14,
                    "textColor": "#0070D2",
                    "selectedTab": {
                        "textColor": "#FFFFFF",
                        "backgroundColor": "#0070D2",
                        "borderEdges": [
                            "all"
                        ],
                        "borderColor": "#C6D3E1",
                        "borderWidth": 1
                    },
                    "step": "StaticSAQLMeasureNames"
                }
            },
            "chart_1": {
                "type": "chart",
                "parameters": {
                    "visualizationType": "hbar",
                    "title": {
                        "label": "",
                        "fontSize": 14,
                        "subtitleLabel": "",
                        "subtitleFontSize": 11,
                        "align": "center"
                    },
                    "theme": "wave",
                    "showValues": true,
                    "axisMode": "multi",
                    "autoFitMode": "keepLabels",
                    "binValues": false,
                    "bins": {
                        "breakpoints": {
                            "low": 0,
                            "high": 100
                        },
                        "bands": {
                            "low": {
                                "label": "",
                                "color": "#B22222"
                            },
                            "medium": {
                                "label": "",
                                "color": "#FFA500"
                            },
                            "high": {
                                "label": "",
                                "color": "#008000"
                            }
                        }
                    },
                    "dimensionAxis": {
                        "showAxis": true,
                        "showTitle": true,
                        "title": "",
                        "customSize": "auto",
                        "icons": {
                            "useIcons": false,
                            "iconProps": {
                                "column": "",
                                "fit": "cover",
                                "type": "round"
                            }
                        }
                    },
                    "measureAxis1": {
                        "sqrtScale": false,
                        "showAxis": true,
                        "customDomain": {
                            "showDomain": false
                        },
                        "showTitle": true,
                        "title": ""
                    },
                    "measureAxis2": {
                        "sqrtScale": false,
                        "showAxis": true,
                        "customDomain": {
                            "showDomain": false
                        },
                        "showTitle": true,
                        "title": ""
                    },
                    "legend": {
                        "show": true,
                        "showHeader": true,
                        "inside": false,
                        "descOrder": false,
                        "position": "right-top",
                        "customSize": "auto"
                    },
                    "tooltip": {
                        "customizeTooltip": false,
                        "showDimensions": true,
                        "dimensions": "",
                        "showMeasures": true,
                        "measures": "",
                        "showPercentage": true,
                        "showNullValues": true,
                        "showBinLabel": true
                    },
                    "trellis": {
                        "enable": false,
                        "showGridLines": true,
                        "flipLabels": false,
                        "type": "x",
                        "chartsPerLine": 4,
                        "size": [
                            100,
                            100
                        ]
                    },
                    "applyConditionalFormatting": true,
                    "showActionMenu": true,
                    "exploreLink": true,
                    "step": "lens_1"
                }
            }
        },
        "filters": [],
        "gridLayouts": [
            {
                "name": "Default",
                "numColumns": 12,
                "rowHeight": "normal",
                "version": 1,
                "pages": [
                    {
                        "label": "Untitled",
                        "name": "36d03d4a-cdce-427e-b338-4ae29db1ba26",
                        "widgets": [
                            {
                                "row": 0,
                                "column": 6,
                                "rowspan": 2,
                                "colspan": 6,
                                "name": "pillbox_3",
                                "widgetStyle": {}
                            },
                            {
                                "row": 2,
                                "column": 6,
                                "rowspan": 2,
                                "colspan": 6,
                                "name": "pillbox_4",
                                "widgetStyle": {}
                            },
                            {
                                "row": 0,
                                "column": 0,
                                "rowspan": 4,
                                "colspan": 6,
                                "name": "chart_1",
                                "widgetStyle": {}
                            }
                        ],
                        "navigationHidden": false
                    }
                ],
                "selectors": [],
                "style": {
                    "backgroundColor": "#F2F6FA",
                    "gutterColor": "#C5D3E0",
                    "cellSpacingX": 8,
                    "cellSpacingY": 8,
                    "fit": "original",
                    "alignmentX": "left",
                    "alignmentY": "top"
                }
            }
        ],
        "dataSourceLinks": [],
        "widgetStyle": {
            "backgroundColor": "#FFFFFF",
            "borderEdges": [],
            "borderColor": "#E6ECF2",
            "borderWidth": 1,
            "borderRadius": 0
        }
    },
    "datasets": [
        {
            "id": "Edgemart13",
            "name": "OpportunityWithAccount",
            "label": "Opportunity With Accounts",
            "url": "../../WaveCommon/repo/edgemarts/OpportunityWithAccount/OpportunityWithAccountEM"
        }
    ]
}

```

**note:** If you bind a measure or grouping in a compact-form or SAQL-form step 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).

**note:** If you provide an aggregate function for a measure, then the measure value must be a string, not an array.
