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

# IElementsQuery

- Package: [@gooddata/sdk-backend-spi](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/index.md)
- Kind: interface
- Source: https://github.com/gooddata/gooddata-ui-sdk/blob/rel/11.64/libs/sdk-backend-spi/src/workspace/attributes/elements/index.ts
- Guides: [Working with attributes](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/data-model/attributes/index.md)

Service to query valid attribute elements for particular display form.

**Signature:**

```typescript
export interface IElementsQuery extends ICancelable<IElementsQuery> 
```
**Extends:** [ICancelable](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.icancelable/index.md)&lt;[IElementsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md)&gt;

## Methods

| Method | Description |
| --- | --- |
| [query()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md#ielementsqueryquery) | Starts the valid elements query. |
| [withAttributeFilters(filters)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md#ielementsquerywithattributefilters) | Sets the attribute filters that will limit the available elements |
| [withAvailableElementsOnly(validateBy)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md#ielementsquerywithavailableelementsonly) | Sets the catalog objects based on which the elements are validated, i.e., if set, only the elements that are available with these metrics, attributes, etc. are returned. Note that this functionality is not supported by every backend. |
| [withDateFilters(filters)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md#ielementsquerywithdatefilters) | Sets the date filters that will limit the available elements |
| [withLimit(limit)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md#ielementsquerywithlimit) | Sets number of valid elements to return per page. Default limit is specific per backend |
| [withMeasures(measures)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md#ielementsquerywithmeasures) | Sets the measures that will limit the available elements - only elements for which the measures have data will be returned. |
| [withOffset(offset)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md#ielementsquerywithoffset) | Sets starting point for the query. Backend WILL return no data if the offset is greater than total number of valid elements. Default offset: 0 |
| [withOptions(options)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md#ielementsquerywithoptions) | Allows to specify advanced options for the elements query. |

## Method details

### IElementsQuery.query()

Starts the valid elements query.

**Signature:**

```typescript
query(): Promise<IElementsQueryResult>;
```
**Returns:**

Promise&lt;[IElementsQueryResult](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsqueryresult/index.md)&gt;

promise of first page of the results

### IElementsQuery.withAttributeFilters()

Sets the attribute filters that will limit the available elements

**Signature:**

```typescript
withAttributeFilters(filters: IElementsQueryAttributeFilter[]): IElementsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| filters | [IElementsQueryAttributeFilter](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsqueryattributefilter/index.md)[] | attribute filters limiting the elements |

**Returns:**

[IElementsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md)

element query

### IElementsQuery.withAvailableElementsOnly()

Sets the catalog objects based on which the elements are validated, i.e., if set, only the elements that are available with these metrics, attributes, etc. are returned.

Note that this functionality is not supported by every backend.

**Signature:**

```typescript
withAvailableElementsOnly(validateBy: ObjRef[]): IElementsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| validateBy | [ObjRef](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.objref/index.md)[] | metric, attributes, or other objects the elements are validated by. |

**Returns:**

[IElementsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md)

element query

### IElementsQuery.withDateFilters()

Sets the date filters that will limit the available elements

**Signature:**

```typescript
withDateFilters(filters: (IRelativeDateFilter | IAbsoluteDateFilter)[]): IElementsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| filters | ([IRelativeDateFilter](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.irelativedatefilter/index.md) \| [IAbsoluteDateFilter](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.iabsolutedatefilter/index.md))[] | date filters limiting the elements |

**Returns:**

[IElementsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md)

element query

### IElementsQuery.withLimit()

Sets number of valid elements to return per page. Default limit is specific per backend

**Signature:**

```typescript
withLimit(limit: number): IElementsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| limit | number | desired max number of valid elements per page; must be a positive number |

**Returns:**

[IElementsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md)

element query

### IElementsQuery.withMeasures()

Sets the measures that will limit the available elements - only elements for which the measures have data will be returned.

**Signature:**

```typescript
withMeasures(measures: IMeasure[]): IElementsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| measures | [IMeasure](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.imeasure/index.md)[] | measures limiting the elements |

**Returns:**

[IElementsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md)

element query

### IElementsQuery.withOffset()

Sets starting point for the query. Backend WILL return no data if the offset is greater than total number of valid elements. Default offset: 0

**Signature:**

```typescript
withOffset(offset: number): IElementsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| offset | number | zero indexed, must be non-negative |

**Returns:**

[IElementsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md)

element query

### IElementsQuery.withOptions()

Allows to specify advanced options for the elements query.

**Signature:**

```typescript
withOptions(options: IElementsQueryOptions): IElementsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| options | [IElementsQueryOptions](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsqueryoptions/index.md) | advanced options |

**Returns:**

[IElementsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ielementsquery/index.md)

element query
