> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Cognite Data Fusion (CDF) is an industrial DataOps platform. Prefer English docs unless the user asks for another locale.
> Follow /_llms/ index links recursively until you reach page URLs ending in .md. Fetch those Markdown twins instead of HTML.
> For REST APIs, default to calendar version 20230101 (stable). Use 20230101-beta or 20230101-alpha only if the user is on a preview API. Cite paths under /api-reference/concepts/<version>/ and the Cdf-Version header. Prefer the Python SDK (cognite-sdk) unless the user is in JavaScript/TypeScript.
> Start here by task: platform overview /cdf/index.md; data modeling /cdf/dm/index.md; data integration /cdf/integration/index.md; access /cdf/access/index.md; CDF Toolkit /cdf/deploy/cdf_toolkit/index.md; REST quickstart /dev/quickstart.md; Python SDK https://cognite-sdk-python.readthedocs-hosted.com/en/stable/; Atlas AI /cdf/atlas_ai/concepts/index.md; Flows apps /cdf/flows/index.md; MCP and IDE setup /dev/guides/ide_ai_integration.md.
> For implementation work, also load /skill.md.

# Creating variables from asset queries

> Create Grafana dashboard variables from asset queries with the deprecated Assets tab, and chain them to navigate an asset hierarchy.

> [!WARNING]
>
> **Deprecated**: Asset-centric APIs and workflows are deprecated. Upgrade your data and applications to data modeling with the [migration plugin](https://docs.cognite.com/cdf/deploy/cdf_toolkit/guides/plugins/migration_plugin.md).
>
> See [Deprecated and retired features](https://docs.cognite.com/cdf/deprecated.md) for dates, and [Data modeling status for CDF projects](https://docs.cognite.com/cdf/dm/dm_concepts/dm_data_modeling_status.md) for how `DATA_MODELING_ONLY` and `HYBRID` projects behave.

For new dashboards, [create variables from GraphQL queries](https://docs.cognite.com/cdf/dashboards/guides/grafana/variables.md) instead.

Use the Assets tab of the variable editor to populate a dashboard variable with assets from an asset query, and chain variables to let users navigate an asset hierarchy. Use the `$variable` or `[[variable]]` syntax to insert the variable in queries.

## Before you begin

* [Create a dashboard](https://docs.cognite.com/cdf/dashboards/guides/grafana/create_dashboard.md) that uses the Cognite Data Source for Grafana.
* Make sure the asset-centric features are [turned on](https://docs.cognite.com/cdf/dashboards/guides/grafana/admin_oidc.md#feature-flags). The variable editor then shows an Assets tab. A variable that's already saved on the Assets tab keeps that tab if you turn off the feature flag, so you can still edit existing dashboards.

## Create a variable from an asset query

**1. Open variables settings**

Navigate to your dashboard's settings, and select Variables from the left-hand side.

**2. Configure the data source**

Set Type to Query, and select your Cognite Data Source as the Data source. Then select the Assets tab.

**3. Enter the query**

In the Query field, enter the query to fetch and filter assets from Cognite Data Fusion (CDF).

For example, this query requests assets with the parameter `parentIds=[123]` and filters the results by `name` that matches the `test-.*` regular expression:

```text theme={"languages":{"custom":["/_languages/kuiper.json"]}}
assets{parentIds=[123], name=~"test-.*"}
```

> [!TIP]
>
> For a list of **valid parameters**, see [the API documentation](https://docs.cognite.com/api-reference/concepts/20230101/assets.md).
>
> See [Filter time series in custom queries](https://docs.cognite.com/cdf/dashboards/guides/grafana/timeseries_legacy.md#filtering) to learn how to **filter** the results.
>
> You can **format variables** to fit into the query, for instance, if you have a multi-value variable like `ts{assetIds=[${variable:csv}]}`.
>
> If you select several assets from the dropdown, the variable is serialized to comma-separated values. Learn more about the variable format options in the [Grafana documentation](https://grafana.com/docs/grafana/latest/variables/advanced-variable-format-options).

**4. Select the value**

In the Value field, select the asset field the variable holds: Id, ExternalId, or Name.

**5. Save the variable**

Select Update.

## Nested (chained) variables

With nested variables, you can create a template to visualize time series related to a branch of the asset subtree and let users navigate the subtree. Nested variables use [asset queries](#create-a-variable-from-an-asset-query). For data models, chain GraphQL variables instead. See [Chain variables](https://docs.cognite.com/cdf/dashboards/guides/grafana/variables.md#chain-variables).

**1. Create nested variables**

Create the necessary nested variables.

![Link variables](https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dashboards/grafana/nested_variables_0.png)

**2. Use the variable as a filter**

Use the variable as the asset filter on the dashboard.

![Use the variable on the dashboard](https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dashboards/grafana/nested_variables_1.png)

> [!TIP]
>
> Users can choose assets on each level of the hierarchy.
>
> ![Select assets from the dropdown](https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dashboards/grafana/nested_variables_2.png)

## Further reading

* [Creating dashboard variables](https://docs.cognite.com/cdf/dashboards/guides/grafana/variables.md)
* [Plot time series with legacy features](https://docs.cognite.com/cdf/dashboards/guides/grafana/timeseries_legacy.md)
