# Equality Filter Interactions

You can bind filters based on certain conditions. CRM Analytics supports multiple operators that provide flexibility when defining the conditions.

## Filter Example (SAQL Form)

Let's say you have these results from the source query.

```json
[
    {grouping: "first", measure: 19}
    {grouping: "second", measure: 32}
]
```

You can bind a filter using the `asEquality()` interaction function. This filter condition determines whether the returned value equals `“bar"`.

```javascript
q = filter q by {{cell(stepFoo.selection, 1, "measure").asEquality("bar")}};
```

After evaluating the interaction based on the data returned from the source query, CRM Analytics produces this filter.

```javascript
q = filter q by bar == 32;
```

:::note
If a selection returns multiple values, `asEquality()` inserts the `'in'` operator, instead of `==`, in the filter statement. For example, this filter condition determines if any value in the `“grouping”` column equals `“bar”`.

```javascript
q = filter q by {{column(stepFoo.selection, ["grouping"]).asEquality("bar")}};
```

If the selection returns `first` and `second`, the filter becomes:

```javascript
q = filter q by bar in ["first","second"];
```
:::

## Filter Example with the in Operator (Compact Form)

Let’s say you want to filter the Case by Status widget in this dashboard based on the account selected in the Account list widget.

![The Account list widget filters the other widgets in the dashboard based on the selected account.](https://a.sfdcstatic.com/developer-website/sfdocs/analytics/media/bi_dev_guide_bindings/bi_dashboard_binding_query_filter_compact_form.png)

Faceting doesn’t work in this case because the queries on these widgets are based on different datasets. To enable filtering, create an interaction in the Cases by Status widget’s query (`Status_1`) based on the selection in the Account widget’s query (`AccountId_Name_1`). This interaction compares the value of the `AccountId.Name` field in the `Status_1` query to the selected values in the `AccountId.Name` field of the `AccountId_Name_1` query. Because there can be multiple selected account names, use the `in` operator.

```json
"steps": {
	"Status_1": {
		"datasets": [{
			"id": "0FbB00000000rlDKAQ",
			"label": "CasesAccounts",
			"name": "CasesAccounts",
			"url": "/services/data/v38.0/wave/datasets/0FbB00000000rlDKAQ"
		}],
		"isFacet": true,
		"isGlobal": false,
		"query": {
			"measures": [
				[
					"count",
					"*"
				]
			],
			"groups": [
				"Status"
			],
			"filters": [
				[
					"AccountId.Name",
					"{{column(AccountId_Name_1.selection, [\\"AccountId.Name\\"]).asObject()}}",
					"in"
				]
			]
		},
		"type": "aggregateflex",
		"useGlobal": true,
		"visualizationParameters": {
			"visualizationType": "hbar",
			"options": {}
		}
	},
	"AccountId_Name_1": {
		"datasets": [{
			"id": "0FbB00000000rlIKAQ",
			"label": "OpptiesAccountsSICsUsers",
			"name": "OpptiesAccountsSICsUsers",
			"url": "/services/data/v38.0/wave/datasets/0FbB00000000rlIKAQ"
		}],
		"isFacet": true,
		"isGlobal": false,
		"query": {
			"measures": [
				[
					"count",
					"*"
				]
			],
			"groups": [
				"AccountId.Name"
			]
		},
		"selectMode": "single",
		"type": "aggregateflex",
		"useGlobal": false,
		"visualizationParameters": {
			"options": {}
		}
	}
...
```

## Filter Example with an Inequality Operator (SAQL Form)

Let's say you have these results from a source query.

```json
[ {grouping: "first", measure: 19} {grouping: "second", measure: 32} ]
```

You can create a filter interaction using on an inequality operator.

```javascript
q = filter q by bar > {{cell(queryFoo.selection, 1, "measure").asString()}};
```

After evaluating the interaction, the filter becomes:

```javascript
q = filter q by bar > 32;
```

## Filter Example with the matches Operator (SAQL Form)

Let's say you have these results from a source query.

```json
[ {grouping: "first", measure: 19} {grouping: "second", measure: 32} ]
```

You can create a filter interaction using on the matches operator.

```javascript
q = filter q by bar matches "{{cell(queryFoo.selection, 1, "grouping").asString()}}";
```

After evaluating the interaction, the filter results are:

```javascript
q = filter q by bar matches "second";
```
