> Documentation index: https://www.gooddata.ai/docs/gooddata-ui/llms.txt lists every page of these docs as Markdown.

# applyAttributeFilter()

- Package: [@gooddata/sdk-ui-dashboard](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui-dashboard/index.md)
- Kind: function
- Source: https://github.com/gooddata/gooddata-ui-sdk/blob/rel/11.64/libs/sdk-ui-dashboard/src/model/commands/filters.ts

Creates the ChangeAttributeFilterSelection command.

**Signature:**

```typescript
export declare function applyAttributeFilter(filterLocalId: string, filter: IAttributeFilter, correlationId?: string): ChangeAttributeFilterSelection | ReplaceAttributeFilterItemSelection | undefined;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| filterLocalId | string | dashboard attribute filter's local id |
| filter | [IAttributeFilter](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.iattributefilter/index.md) | attribute filter to apply |
| correlationId | string | _(Optional)_ specify correlation id to use for this command. this will be included in all events that will be emitted during the command processing |

**Returns:**

[ChangeAttributeFilterSelection](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui-dashboard/sdk-ui-dashboard.changeattributefilterselection/index.md) &#124; [ReplaceAttributeFilterItemSelection](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui-dashboard/sdk-ui-dashboard.replaceattributefilteritemselection/index.md) &#124; undefined

## Remarks

Dispatching this command will result in application of element selection for the dashboard attribute filter with the provided id, or error in case of invalid update (e.g. non-existing `filterLocalId`).

The [ChangeAttributeFilterSelectionPayload](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui-dashboard/sdk-ui-dashboard.changeattributefilterselectionpayload/index.md)'s `selectionType` and `elements` are derived from the provided attribute filter.

To convert [IDashboardFilter](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui-dashboard/sdk-ui-dashboard.idashboardfilter/index.md) to [IFilter](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.ifilter/index.md) use [dashboardAttributeFilterToAttributeFilter()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.dashboardattributefiltertoattributefilter/index.md). Converted filter can be used within the command's payload.
