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

# useExecutionDataView

> Fetch execution data as a DataViewFacade from a prepared execution or inline seriesBy/slicesBy configuration.

API reference: [useExecutionDataView()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.useexecutiondataview/index.md) (function)

React hook to get data for a specific execution. Use it for ad-hoc executions; to load the data of a saved visualization, use [useInsightDataView](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/use-insight-data-view/index.md).

Accepts either a prepared execution or an execution configuration with measures, attributes, filters, and sorting. Returns a [`DataViewFacade`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.dataviewfacade/index.md) wrapping the execution result.

## [Basic usage](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/use-execution-data-view/#basic-usage)

```tsx
import { useExecutionDataView } from "@gooddata/sdk-ui";
import * as Md from "./catalog.js";

function MyDataComponent() {
    const { result, status, error } = useExecutionDataView({
        execution: {
            seriesBy: [Md.Revenue, Md.Region],
            slicesBy: [Md.DateMonth],
            filters: [],
        },
    });

    if (status === "loading" || status === "pending") {
        return <div>Loading...</div>;
    }

    if (status === "error") {
        return <div>Error: {error?.message}</div>;
    }

    // result is a DataViewFacade
    const data = result?.data().slices().toArray();
    // ...
}
```

## [Parameters](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/use-execution-data-view/#parameters)

| Property | Type | Description |
|----------|------|-------------|
| `execution` | `IPreparedExecution \| IExecutionConfiguration` | Either a prepared execution or inline config with `seriesBy`, `slicesBy`, etc. |
| `execution.seriesBy` | [`AttributesMeasuresOrPlaceholders`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.attributesmeasuresorplaceholders/index.md) | Measures and scoping attributes for data series. |
| `execution.slicesBy` | [`AttributesOrPlaceholders`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.attributesorplaceholders/index.md) | Attributes to slice data series by. |
| `execution.filters` | [`NullableFiltersOrPlaceholders`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.nullablefiltersorplaceholders/index.md) | Server-side filters. |
| `execution.sortBy` | [`SortsOrPlaceholders`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.sortsorplaceholders/index.md) | Server-side sorting. |
| `window` | [`DataViewWindow`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.dataviewwindow/index.md) | Load only a specific window of data (for paging). |
| `backend` | [`IAnalyticalBackend`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ianalyticalbackend/index.md) | Backend override (defaults to [`BackendProvider`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.backendprovider/index.md) context). |
| `workspace` | `string` | Workspace override (defaults to [`WorkspaceProvider`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.workspaceprovider/index.md) context). |

## [Return value](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/use-execution-data-view/#return-value)

`UseCancelablePromiseState<DataViewFacade, GoodDataSdkError>`, the same shape as [useCancelablePromise](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/use-cancelable-promise/index.md) returns.

| Field | Type | Description |
|-------|------|-------------|
| `status` | `"pending" \| "loading" \| "success" \| "error"` | Current state of the load. |
| `result` | `DataViewFacade \| undefined` | The loaded data view. Set only in the `"success"` state. |
| `error` | `GoodDataSdkError \| undefined` | The error. Set only in the `"error"` state. |

## [States](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/use-execution-data-view/#states)

| `status` | `result` | `error` | When |
|----------|----------|---------|------|
| `"pending"` | `undefined` | `undefined` | `execution` is not provided. |
| `"loading"` | `undefined` | `undefined` | The execution is running or its data is being read. |
| `"success"` | [`DataViewFacade`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.dataviewfacade/index.md) | `undefined` | The data view for `window` (or all data when `window` is not set) was read. |
| `"error"` | `undefined` | [`GoodDataSdkError`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.gooddatasdkerror/index.md) | The execution or data read failed. The error is converted to a [`GoodDataSdkError`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.gooddatasdkerror/index.md) subtype. |

## [When it re-runs](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/use-execution-data-view/#when-it-re-runs)

The hook starts a new load when any of these change:

- `backend` or `workspace` (the effective values, including context values). `backend` is compared by reference, `workspace` by value.
- The fingerprint of the prepared execution. An inline `execution` configuration is compared by its content, not by object identity.
- `window.offset` or `window.size`, compared by reference.
- `enableExecutionCancelling`.
- Any item in the optional second argument, `deps`.

When a load is superseded or the component unmounts before it finishes, its result is ignored and `onCancel` is called. The request itself keeps running unless `enableExecutionCancelling` is `true`; then the hook aborts the execution's signal and the request is canceled.

## [Notes](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/use-execution-data-view/#notes)

- Without a `backend` prop or a [`BackendProvider`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.backendprovider/index.md), the hook throws: "useExecutionDataView: IAnalyticalBackend must be defined. Either pass it as a parameter or make sure there is a BackendProvider up the component tree." A missing workspace throws the matching [`WorkspaceProvider`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.workspaceprovider/index.md) error.
- The `backend` and `workspace` props take precedence over the context values.
- `seriesBy`, `slicesBy`, `totals`, `filters`, and `sortBy` in an execution configuration can contain placeholders. Pass `placeholdersResolutionContext` for composed placeholders. The object is treated as a configuration only when it has `seriesBy`.
- `window.offset` and `window.size` are arrays compared by reference. Keep them stable (for example with `useMemo`); a new array on every render starts a new load on every render.
- Unlike [Execute](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/execute/index.md), the hook does not turn a no-data error into an empty result. It returns the `"error"` state with the converted error.
- The callbacks `onLoading`, `onPending`, `onSuccess`, `onError`, and `onCancel` are passed to `useCancelablePromise`. Changing them does not start a new load.

## [Props](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/use-execution-data-view/#props)

| Prop | Type | Required | Description | Inherited from |
|------|------|----------|-------------|----------------|
| [`backend`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iuseexecutiondataviewconfig/index.md#iuseexecutiondataviewconfigbackend) | [`IAnalyticalBackend`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ianalyticalbackend/index.md) | No | Backend to work with. | — |
| [`enableExecutionCancelling`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iuseexecutiondataviewconfig/index.md#iuseexecutiondataviewconfigenableexecutioncancelling) | `boolean` | No | Optionally enable real execution cancellation. This means that if the execution request is not yet finished and the execution changes, the request will be cancelled and the new execution will be started. Default: false | — |
| [`execution`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iuseexecutiondataviewconfig/index.md#iuseexecutiondataviewconfigexecution) | [`IPreparedExecution`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md) `\|` [`IExecutionConfiguration`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iexecutionconfiguration/index.md) | No | Prepared execution, or execution configuration for which you want to get the data view. | — |
| [`window`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iuseexecutiondataviewconfig/index.md#iuseexecutiondataviewconfigwindow) | [`DataViewWindow`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.dataviewwindow/index.md) | No | You can define only a specific "window" of data to load. | — |
| [`workspace`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iuseexecutiondataviewconfig/index.md#iuseexecutiondataviewconfigworkspace) | `string` | No | Workspace where execution should be executed. | — |
